octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #42979] textscan.m, strread.m: parsing of form


From: Philip Nienhuis
Subject: [Octave-bug-tracker] [bug #42979] textscan.m, strread.m: parsing of format conversion specifiers and % literals
Date: Wed, 13 Aug 2014 19:50:17 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:25.0) Gecko/20100101 Firefox/25.0 Iceape/2.22

URL:
  <http://savannah.gnu.org/bugs/?42979>

                 Summary: textscan.m, strread.m: parsing of format conversion
specifiers and % literals
                 Project: GNU Octave
            Submitted by: philipnienhuis
            Submitted on: Wed 13 Aug 2014 09:50:16 PM CEST
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: Patch Submitted
             Assigned to: philipnienhuis
         Originator Name: Philip Nienhuis
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.8.0
        Operating System: Any

    _______________________________________________________

Details:

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


>> strread ("Total: 32.5 % (of cm values)", "Total: %f % (of cm values)")
error: strread: the number of output variables must match that specified by
FORMAT
error: called from:
error:   /usr/local/share/octave/3.9.0+/m/io/strread.m at line 200, column 5
>> textscan ("Total: 32.5 % (of cm values)", "Total: %f % (of cm values)")
error: strread: unknown format specifier #2 ('%')
>>


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.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 13 Aug 2014 09:50:16 PM CEST  Name: fmtconvspec.cs  Size: 3kB   By:
philipnienhuis

<http://savannah.gnu.org/bugs/download.php?file_id=31899>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42979>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]