changeset 12985:8df8b402797d

maint: periodic merge of stable to default
author John W. Eaton <jwe@octave.org>
date Mon, 22 Aug 2011 20:30:14 -0400
parents 5e37369ea13c (current diff) 7626f8934466 (diff)
children 4a39209844f4
files src/oct-stream.cc
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/oct-stream.cc
+++ b/src/oct-stream.cc
@@ -1379,7 +1379,9 @@
     tmp[n++] = static_cast<char> (c); \
  \
   if (n > 0 && c == EOF) \
-    is.clear ()
+    is.clear (); \
+ \
+  tmp.resize (n)
 
 // For a `%s' format, skip initial whitespace and then read until the
 // next whitespace character or until WIDTH characters have been read.
--- a/test/test_io.m
+++ b/test/test_io.m
@@ -242,6 +242,9 @@
 %% test/octave.test/io/puts-4.m
 %!error <Invalid call to puts.*> puts (1, 2);
 
+%!assert (sscanf ('123456', '%10c'), '123456')
+%!assert (sscanf ('123456', '%10s'), '123456')
+
 %% test/octave.test/io/sscanf-1.m
 %!test
 %! [a, b, c] = sscanf ("1.2 3 foo", "%f%d%s", "C");