Mercurial > octave
diff libinterp/corefcn/file-io.cc @ 27137:30f53f7a7293
Return correct error messages on octave-streams when scanf fails (bug #56396)
* file-io.cc (Fsscanf): Add BIST test for bug #56396.
* oct-stream.cc (base_stream::do_scanf): Perform end-of-scan processing if EOF
has been detected, not just when FAILBIT has been set. If FAILBIT has been
set, call error() to set an error message on the octave-stream. At end of
function, assign any partial results obtained to output. Don't require that
all conversions were successful.
* io.tst: Update BIST tests to reflect new Matlab-compatible behavior for error
message output.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 03 Jun 2019 09:04:41 -0700 |
parents | 04e5cb5e2cb3 |
children | ec6d31ef6bb6 |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Sat Jun 01 21:01:45 2019 -0700 +++ b/libinterp/corefcn/file-io.cc Mon Jun 03 09:04:41 2019 -0700 @@ -1166,6 +1166,15 @@ return retval; } +/* +%!test <*56396> +%! [val, count, errmsg, nextpos] = sscanf ('1234a6', '%2d', 3); +%! assert (val, [12; 34]); +%! assert (count, 2); +%! assert (errmsg, "sscanf: format failed to match"); +%! assert (nextpos, 5); +*/ + DEFMETHOD (scanf, interp, args, , doc: /* -*- texinfo -*- @deftypefn {} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})