# HG changeset patch # User John W. Eaton # Date 1314059414 14400 # Node ID 8df8b402797d01c70838cbea8a0f1ca208db752f # Parent 5e37369ea13c0a404ca7e791e393029a16e8279d# Parent 7626f893446639b7997918f1adab54a1d6e2626a maint: periodic merge of stable to default diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -1379,7 +1379,9 @@ tmp[n++] = static_cast (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. diff --git a/test/test_io.m b/test/test_io.m --- a/test/test_io.m +++ b/test/test_io.m @@ -242,6 +242,9 @@ %% test/octave.test/io/puts-4.m %!error 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");