changeset 5338:c4b55d47122e

[project @ 2005-05-05 17:28:51 by jwe]
author jwe
date Thu, 05 May 2005 17:28:51 +0000
parents 7ffada2604ea
children 4266ef7972b2
files liboctave/Array.cc liboctave/ChangeLog src/ChangeLog src/oct-stream.cc
diffstat 4 files changed, 48 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
 
--- 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  <jwe@octave.org>
+
+	* Array.cc (Array<T>::permute): Call chop_trailing_singletons on
+	retval before return.
+
 2005-05-04  John W. Eaton  <jwe@octave.org>
 
 	* cmd-edit.cc (gnu_readline::do_readline): Extract const char*
--- 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  <jwe@octave.org>
+
+	* oct-stream.cc (BEGIN_S_CONVERSION): Correctly handle width
+	specifiers.
+
 2005-05-04  John W. Eaton  <jwe@octave.org>
 
 	* ls-mat5.cc (read_mat5_binary_element): Implement reading of N-d
--- 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<char> (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<char> (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)