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

 
 

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

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Tue 08 Mar 2011 08:46:51 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Philip NienhuisOpen/Closed: Closed
Release: devOperating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project 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>
Project Member

 

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

Attach File(s):
   
   
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
  • -unavailable- added by rik5 (Posted a comment)
  • -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 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 22 Jul 2011 09:02:36 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 08 Mar 2011 08:46:51 PM UTCphilipnienhuisAttached 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.1-cleanup1