# HG changeset patch # User jwe # Date 1201679058 0 # Node ID ccf8e0410ee0f87edaa6e81f690d142f1088f1e7 # Parent 81f0e11253e9f303a02e974981d128f810c27419 [3-0-0-branch @ 2008-01-30 07:44:17 by jwe] diff -r 81f0e11253e9 -r ccf8e0410ee0 scripts/ChangeLog --- a/scripts/ChangeLog Mon Jan 28 19:40:41 2008 +0000 +++ b/scripts/ChangeLog Wed Jan 30 07:44:18 2008 +0000 @@ -1,3 +1,7 @@ +2008-01-30 John W. Eaton + + * strings/deblank.m: Improve compatibility. + 2008-01-28 Michael Goffioul * plot/xlabel.m, plot/ylabel.m, plot/zlabel.m: diff -r 81f0e11253e9 -r ccf8e0410ee0 scripts/strings/deblank.m --- a/scripts/strings/deblank.m Mon Jan 28 19:40:41 2008 +0000 +++ b/scripts/strings/deblank.m Wed Jan 30 07:44:18 2008 +0000 @@ -34,13 +34,23 @@ print_usage (); endif - if (ischar (s)) + char_arg = ischar (s); + + if (char_arg || isnumeric (s)) - k = find (! isspace (s) & s != "\0"); - if (isempty (s) || isempty (k)) - s = ""; - else - s = s(:,1:ceil (max (k) / rows (s))); + if (! isempty (s)) + if (char_arg) + k = find (! isspace (s) & s != "\0"); + else + warning ("deblank: expecting character string argument") + k = find (s != 0); + endif + + if (isempty (k)) + s = resize (s, 0, 0); + else + s = s(:,1:ceil (max (k) / rows (s))); + endif endif elseif (iscell(s)) @@ -48,7 +58,7 @@ s = cellfun (@deblank, s, "UniformOutput", false); else - error ("deblank: expecting string argument"); + error ("deblank: expecting character string argument"); endif endfunction diff -r 81f0e11253e9 -r ccf8e0410ee0 src/ChangeLog --- a/src/ChangeLog Mon Jan 28 19:40:41 2008 +0000 +++ b/src/ChangeLog Wed Jan 30 07:44:18 2008 +0000 @@ -1,3 +1,9 @@ +2008-01-28 John W. Eaton + + * oct-stream.cc (BEGIN_CHAR_CLASS_CONVERSION): Handle width properly. + (OCTAVE_SCAN) [__GNUG__ && ! CXX_ISO_COMPLIANT_LIBRARY]: + Delete special case. + 2008-01-28 David Bateman * ov-mapper.cc (SPARSE_MAPPER_LOOP_2): Use data method instead of diff -r 81f0e11253e9 -r ccf8e0410ee0 src/oct-stream.cc --- a/src/oct-stream.cc Mon Jan 28 19:40:41 2008 +0000 +++ b/src/oct-stream.cc Wed Jan 30 07:44:18 2008 +0000 @@ -1039,12 +1039,6 @@ return do_gets (max_len, err, false, who); } -#if defined (__GNUG__) && ! defined (CXX_ISO_COMPLIANT_LIBRARY) - -#define OCTAVE_SCAN(is, fmt, arg) is.scan ((fmt).text, arg) - -#else - #define OCTAVE_SCAN(is, fmt, arg) octave_scan (is, fmt, arg) template @@ -1339,8 +1333,6 @@ return is; } -#endif - template void do_scanf_conv (std::istream& is, const scanf_format_elt& fmt, @@ -1547,45 +1539,37 @@ \ do \ { \ - if (width) \ - { \ - char *tbuf = new char[width+1]; \ + if (! width) \ + width = INT_MAX; + + std::ostringstream buf; \ + \ + std::string char_class = elt->char_class; \ \ - OCTAVE_SCAN (is, *elt, tbuf); \ + int c = EOF; \ \ - tbuf[width] = '\0'; \ - tmp = tbuf; \ - delete [] tbuf; \ + if (elt->type == '[') \ + { \ + int chars_read = 0; \ + while (is && chars_read++ < width && (c = is.get ()) != EOF \ + && char_class.find (c) != NPOS) \ + buf << static_cast (c); \ } \ else \ { \ - std::ostringstream buf; \ - \ - std::string char_class = elt->char_class; \ - \ - int c = EOF; \ + int chars_read = 0; \ + while (is && chars_read++ < width && (c = is.get ()) != EOF \ + && char_class.find (c) == NPOS) \ + buf << static_cast (c); \ + } \ \ - if (elt->type == '[') \ - { \ - while (is && (c = is.get ()) != EOF \ - && char_class.find (c) != NPOS) \ - buf << static_cast (c); \ - } \ - else \ - { \ - while (is && (c = is.get ()) != EOF \ - && char_class.find (c) == NPOS) \ - buf << static_cast (c); \ - } \ + if (width == INT_MAX && c != EOF) \ + is.putback (c); \ \ - if (c != EOF) \ - is.putback (c); \ + tmp = buf.str (); \ \ - tmp = buf.str (); \ - \ - if (tmp.empty ()) \ - is.setstate (std::ios::failbit); \ - } \ + if (tmp.empty ()) \ + is.setstate (std::ios::failbit); \ } \ while (0)