bugGNU Octave - Bugs: bug #42979, textscan.m, strread.m: parsing of...

 
 

bug #42979: textscan.m, strread.m: parsing of format conversion specifiers and % literals

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Wed 13 Aug 2014 07:50:16 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Philip Nienhuis <philipnienhuis>
Originator Name: Philip NienhuisOpen/Closed: Closed
Release: 3.8.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 25 Aug 2014 07:43:10 PM UTC, comment #1:

Pushed to default
(http://hg.savannah.gnu.org/hgweb/octave/rev/c573d9c70ae5)

Philip Nienhuis <philipnienhuis>
Project MemberIn charge of this item.
Wed 13 Aug 2014 07:50:16 PM UTC, original submission:

Consider calls to strread.m and textscan.m of the form:

For a start, both functions should yield identical error messages for this case.

As to the first case, strread.m incorrectly assesses the number of format conversion specifiers; it is fooled by the lone "%" appearing as a literal.
In the second case, textscan.m assesses a wrong number of (valid) format conversion specifiers, hands them to strread.m (and on the way prepares strread.m to return two output args), upon which strread.m only then incorrectly concludes it is given an invalid format specifier #2.

Attached is a fix for both functions invoking a regexp for assessing the number of valid format conversion specifiers, and it also improves the error messages returned by strread and adds some tests.

Note that Matlab doesn't seem to accept a lone "%" as a literal. Of course a literal "%" can be read away with a %*1s format conversion specifier. So in a way I've made a somewhat arbitrary choice to make strread.m & textscan.m accept a single "%" as a literal.

If no one has any objections I'll push it in a few days.

Philip Nienhuis <philipnienhuis>
Project MemberIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #31899:  fmtconvspec.cs added by philipnienhuis (3KiB - text/x-csharp)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by philipnienhuis (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 25 Aug 2014 07:43:10 PM UTCphilipnienhuisStatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Wed 13 Aug 2014 07:50:16 PM UTCphilipnienhuisAttached File-=>Added fmtconvspec.cs, #31899

    Back to the top


    Powered by Savane 3.1-cleanup1