Mercurial > hg > octave-lyh
changeset 11625:ccf8e0410ee0 release-3-0-x
[3-0-0-branch @ 2008-01-30 07:44:17 by jwe]
author | jwe |
---|---|
date | Wed, 30 Jan 2008 07:44:18 +0000 |
parents | 81f0e11253e9 |
children | 09f833d41f68 |
files | scripts/ChangeLog scripts/strings/deblank.m src/ChangeLog src/oct-stream.cc |
diffstat | 4 files changed, 50 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-01-30 John W. Eaton <jwe@octave.org> + + * strings/deblank.m: Improve compatibility. + 2008-01-28 Michael Goffioul <michael.goffioul@gmail.com> * plot/xlabel.m, plot/ylabel.m, plot/zlabel.m:
--- a/scripts/strings/deblank.m +++ b/scripts/strings/deblank.m @@ -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
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-01-28 John W. Eaton <jwe@octave.org> + + * 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 <dbateman@free.fr> * ov-mapper.cc (SPARSE_MAPPER_LOOP_2): Use data method instead of
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -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 <class T> @@ -1339,8 +1333,6 @@ return is; } -#endif - template <class T> 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<char> (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<char> (c); \ + } \ \ - if (elt->type == '[') \ - { \ - while (is && (c = is.get ()) != EOF \ - && char_class.find (c) != NPOS) \ - buf << static_cast<char> (c); \ - } \ - else \ - { \ - while (is && (c = is.get ()) != EOF \ - && char_class.find (c) == NPOS) \ - buf << static_cast<char> (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)