bugGNU Octave - Bugs: bug #32720, ML compatibility of textread.m and...

 
 

bug #32720: ML compatibility of textread.m and strread.m

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Tue 08 Mar 2011 08:46:51 PM 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:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 22 Jul 2011 09:02:36 PM UTC, comment #1: 

Issues resolved by your changeset <http://hg.savannah.gnu.org/hgweb/octave/rev/fe6e2afcd9ee>.  Closing report.

Rik <rik5>
Group administrator
Tue 08 Mar 2011 08:46:51 PM UTC, original submission:  

I've hit a few incompatibilities betweem Matlab's and Octave's textread.m and strread.m (the two are strongly interlinked in Octave 3.4.x)

1. As per the on-line ML docs, textread's default for whitespace = ' \t\b'  (note the leading space).
Octave's textread as it stands doesn't have a default whitespace setting at all. Instead it simply conveys all given optional param/value pairs as varargin{:} to strread.m and so defaults to strread's default whitespace which is ' \n\r\t\b'  (again, note leading space).
==> This is easy to fix by checking for a default 'whitespace' argument setting in textread and -if needed- adapting varargin.
See attached patch # 1 (diff -cp with mercurial as of 2011-03-08_21:30)

2. As per the ML docs, textread offers an option of preserving leading and trailing spaces by calling it like:
     textread('myfile.txt', '%s', 'whitespace', '')
When I do this in Octave 3.4.0, leading whitespace is consequently trimmed.
Following the internal logic I find that textread.m calls strread.m, which calls an internal subfunction split_by(), which always calls strtrim() (in line 246 of strread.m).
The easiest fix is simply commenting out or deleting the call to strtrim().

3. strread.m accepts a 'whitespace' argument but doesn't do anything with it, except substituting it into 'delimiter' arg if that is not supplied.

4. No checks for empty 'delimiter' or 'whitespace', or overlap in these params are performed.

I've added a few checks, and implemented a -perhaps rough- trick to remove repeated whitespace. Also, in case of a non-empty 'whitespace' setting, strtrim() is called.
==> see patch # 2 (diff -cp with mercurial as of 2011-03-08_21:30)

All tests (of strread) pass and AFAICS ML and Octave behavior is now identical.

I've also added a changelog entry (attachment #3).
Sorry I have no development setup at hand now (I made these fixes using ML at work and octave-3.3.91_MinGW by Tatsuro) so I can't make changesets - I don't even know how to make them.

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 #22859:  textread.m.diff added by philipnienhuis (639B - text/x-patch)
file #22860:  strread.m.diff added by philipnienhuis (4KiB - text/x-patch)
file #22861:  Changelog added by philipnienhuis (287B - 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 rik5 (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-07-22 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2011-03-08 philipnienhuis Attached File- Added textread.m.diff, #22859
        Attached File- Added strread.m.diff, #22860
        Attached File- Added Changelog, #22861

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code