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

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

[Octave-bug-tracker] [bug #37023] strread with leading white space in ne


From: Philip Nienhuis
Subject: [Octave-bug-tracker] [bug #37023] strread with leading white space in new lines
Date: Thu, 16 Aug 2012 09:45:52 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6

Follow-up Comment #2, bug #37023 (project octave):

Your analysis is spot on, Xuejin.
While strread.m by itself parses similar strings OK, this bug was hidden
because of the way strread.m is invoked by textscan.m and textscan.m only has
tests specific to specific textscan options.


octave-3.6.2.exe:23> [a, b] = strread (" 1. 1 \n  2 3 ", "%f %f")
a =
   1
   2
b =
   1
   3


... but:


octave-3.6.2.exe:25> [a, b] = strread (" 1. 1 \n  2 3 \n", "%f %f",
"endofline", "\n")
a =
     1
   NaN
     3
b =
     1
     2


Cause: I didn't realize in full that regexprep() doesn't "do" overlapping
matches. I don't know if that is documented.

Once I'm back at my dev machine I'll push a fix + extra tests (hopefully end
of next week). 
You'll probably have to wait for Octave-3.8 or 4.0, so that's why I suggest
the fix below if you're in a hurry:

FIX (for Octave-3.6.2):
Change lines 378 in strread.m from:

      rxp_dlmwsp = sprintf ('( [%s]|[%s] )', dlmstr, dlmstr);

into these three lines:


      if (! isempty (dlmstr))
        rxp_dlmwsp = sprintf ('( [%s] | [%s]|[%s] )', dlmstr, dlmstr,
dlmstr);
        str = regexprep (str, rxp_dlmwsp, delimiter_str(1));
      endif

(watch out for line wrap!)


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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