bugGNU Octave - Bugs: bug #33971, strread.m: fixed width format...


bug #33971: strread.m: fixed width format specifier extending beyond EOLs

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Tue 09 Aug 2011 06:56:04 AM UTC  
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


Thu 30 Aug 2012 07:20:49 PM UTC, comment #2: 

This bug has already been fixed a long time ago in a collection of patches by me that have been reviewed and committed by Rik. Closing this report

Philip Nienhuis <philipnienhuis>
Project Member
Tue 09 Aug 2011 09:08:54 PM UTC, comment #1: 

Here's a patch to let the user get away with too wide field width specifiers, cf. ML.
Also user-specified last literals wider than the last one on the lines in a file are allowed (but in the file all these have to be identical)

Difference here is that Octave yields a warning in such a situation if detected in the first "line" of the file or string.

Hunks #1 and #2 take care of that.

Hunk #3 is a bug fix needed now for the following situation (w. only hunks #2 & #3):

octave.exe:2> [a, b] = strread ("1 2", "%s %2s")
warning: strread: Field width '%2s' (fmt spec # 2) extends beyond word limit
error: strread: A(I,J): row index out of bounds; value 2 out of bound 1
error: called from:
error:   x:\octave\octave-3.5.0+\share\octave\3.5.0+\m\io\strread.m at line 499, column 11

(I had this mod (hunk #3) in mind for some time but never hit the situation where it was needed - I now see that was because it was catched by the error stmts higher up that hunks #1 & #2 change into a warning.)

My source tree got mixed up, so no hg changeset but a diff -u, sorry.
Proposed changelog:

2011-08-09 Philip Nienhuis <prnienhuis@users.sf.net>

    Allow fixed width format specifiers to extend beyond actual
    word width but give suitable warning (bug #33971)
    Files: strread.m

(file #23773)

Philip Nienhuis <philipnienhuis>
Project Member
Tue 09 Aug 2011 06:56:04 AM UTC, original submission:  

With dev sources strread.m:

octave.exe:3> strread ("5 3", "%2d")
error: strread: Field width '%2d' (fmt spec # 1) extends beyond word limit
error: called from:
error:   C:\home\Philip\Mydocs\octave\strread.m at line 442, column 1

I (we) have to think up what to do if a format with specified width (like %2s) extends beyond an EOL delimiter.
This issue is similar to what I described here:


...about Matlab silently accepting fields being less wide than the format specifier width expects.
We know what ML does then, but perhaps we need to inform the user (by warning rather than error) that the format string doesn't exactly match the file, rather than going on silently.

What do you think?

Philip Nienhuis <philipnienhuis>
Project Member


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

Attach Files:

Attached Files
file #23773:  strread.m.diff_2011aug9#2 added by philipnienhuis (2KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


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

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

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-30 philipnienhuis StatusNone => Fixed
        Open/ClosedOpen => Closed
    2011-08-09 philipnienhuis Attached File- => Added strread.m.diff_2011aug9#2, #23773

    Back to the top

    Powered by Savane 3.5