[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #37023] strread with leading white space in ne
[Octave-bug-tracker] [bug #37023] strread with leading white space in new lines
Thu, 16 Aug 2012 09:45:52 +0000
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:220.127.116.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")
octave-3.6.2.exe:25> [a, b] = strread (" 1. 1 \n 2 3 \n", "%f %f",
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,
str = regexprep (str, rxp_dlmwsp, delimiter_str(1));
(watch out for line wrap!)
Reply to this item at:
Message sent via/by Savannah