# HG changeset patch # User jwe # Date 1115314131 0 # Node ID c4b55d47122e9591160dc1d711a06150640a2086 # Parent 7ffada2604ea9011f2f37aa6504da2440f220a4d [project @ 2005-05-05 17:28:51 by jwe] diff -r 7ffada2604ea -r c4b55d47122e liboctave/Array.cc --- a/liboctave/Array.cc Thu May 05 03:56:25 2005 +0000 +++ b/liboctave/Array.cc Thu May 05 17:28:51 2005 +0000 @@ -496,6 +496,8 @@ increment_index (old_idx, dv); } + chop_trailing_singletons (); + return retval; } diff -r 7ffada2604ea -r c4b55d47122e liboctave/ChangeLog --- a/liboctave/ChangeLog Thu May 05 03:56:25 2005 +0000 +++ b/liboctave/ChangeLog Thu May 05 17:28:51 2005 +0000 @@ -1,3 +1,8 @@ +2005-05-05 John W. Eaton + + * Array.cc (Array::permute): Call chop_trailing_singletons on + retval before return. + 2005-05-04 John W. Eaton * cmd-edit.cc (gnu_readline::do_readline): Extract const char* diff -r 7ffada2604ea -r c4b55d47122e src/ChangeLog --- a/src/ChangeLog Thu May 05 03:56:25 2005 +0000 +++ b/src/ChangeLog Thu May 05 17:28:51 2005 +0000 @@ -1,3 +1,8 @@ +2005-05-05 John W. Eaton + + * oct-stream.cc (BEGIN_S_CONVERSION): Correctly handle width + specifiers. + 2005-05-04 John W. Eaton * ls-mat5.cc (read_mat5_binary_element): Implement reading of N-d diff -r 7ffada2604ea -r c4b55d47122e src/oct-stream.cc --- a/src/oct-stream.cc Thu May 05 03:56:25 2005 +0000 +++ b/src/oct-stream.cc Thu May 05 17:28:51 2005 +0000 @@ -1469,7 +1469,7 @@ delete [] tbuf // For a `%s' format, skip initial whitespace and then read until the -// next whitespace character. +// next whitespace character or until WIDTH characters have been read. #define BEGIN_S_CONVERSION() \ int width = elt->width; \ \ @@ -1478,19 +1478,46 @@ do \ { \ if (width) \ - { \ - char *tbuf = new char [width+1]; \ + { \ + char *tbuf = new char [width+1]; \ + \ + int c = EOF; \ + \ + int n = 0; \ + \ + while (is && (c = is.get ()) != EOF) \ + { \ + if (! isspace (c)) \ + { \ + tbuf[n++] = static_cast (c); \ + break; \ + } \ + } \ \ - OCTAVE_SCAN (is, *elt, tbuf); \ + while (is && n < width && (c = is.get ()) != EOF) \ + { \ + if (isspace (c)) \ + { \ + is.putback (c); \ + break; \ + } \ + else \ + tbuf[n++] = static_cast (c); \ + } \ \ - tbuf[width] = '\0'; \ + tbuf[n] = '\0'; \ + \ + if (n > 0 && c == EOF) \ + is.clear (); \ + \ tmp = tbuf; \ + \ delete [] tbuf; \ - } \ + } \ else \ - { \ - is >> std::ws >> tmp; \ - } \ + { \ + is >> std::ws >> tmp; \ + } \ } \ while (0)