bugGNU Octave - Bugs: bug #42609, strread.m doesn't properly process...

 
 

bug #42609: strread.m doesn't properly process delimiter literals

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Tue 24 Jun 2014 08:31:25 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 26 Jun 2014 06:47:52 PM UTC, comment #3: 

I think do_string_escape is a good idea in any case.

BTW thanks for pushing my patch.
Although I'm not certain it'll cover all cases, would it be OK to close this bug report?

Philip Nienhuis <philipnienhuis>
Group Member
Wed 25 Jun 2014 09:20:27 PM UTC, comment #2: 

Thanks for the patch.  It seems to work if the format is a double quoted string, in which case Octave converts the backslash string escapes to single characters when it parses the double quoted string.  But if the format is a single quoted string, it fails for me:


octave:1> s = sprintf ('1 2 3\n4 5 6\n7 8 9\n');
octave:2> [a, b, c] = strread (s, '%d %d %d\n')
warning: strread: literal '\n' (fmt spec # 4) does not match data
strread: FORMAT does not match data
error: called from 'strread' in file /home/jwe/src/octave-stable/scripts/io/strread.m near line 754, column 13
error: called from:
error:   /home/jwe/src/octave-stable/scripts/io/strread.m at line 764, column 9


My understanding is that this works in Matlab.  Is there any reason that we shouldn't alway do

+verabtim+
if (strcmp (typeinfo (fmt), 'sq_string'))
  fmt = do_string_escapes (fmt);
endif
-verbatim-

at the beginning of strread?

I made that change here:

  http://hg.savannah.gnu.org/hgweb/octave/rev/c32f378e08f3

Let me know if there is some reason to not make this change.

Thanks.

John W. Eaton <jwe>
Group administrator
Tue 24 Jun 2014 08:42:01 PM UTC, comment #1: 

Here's a changeset cf. option 2. in my first post in the relevant maintainers ML thread.

Seems to work OK, all tests (incl. 2 new ones) pass; yet I think there should be more investigation into what Matlab exactly does. I have no time for that now


(file #31613)

Philip Nienhuis <philipnienhuis>
Group Member
Tue 24 Jun 2014 08:31:25 PM UTC, original submission:  

See this discussion on maintainers ML:
http://octave.1599824.n4.nabble.com/newline-in-strread-format-td4664978.html

[a, b, c] = strread ("1 2 3n4 5 6n7 8 9n", "%f %f %fn")

errors out with "strread: FORMAT does not match data"

I'll come up with a first quick patch soon

Philip Nienhuis <philipnienhuis>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #31613:  strread_bug#42609.cs added by philipnienhuis (1KiB - text/x-csharp)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by philipnienhuis (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-08-03 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2014-06-24 philipnienhuis Attached File- Added strread_bug#42609.cs, #31613
        StatusConfirmed Patch Submitted

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code