changeset 31170:bcd75c07c9e8 stable

scanf: Don't set error when reaching end of stream (bug #62723). * libinterp/corefcn/oct-stream.cc (base_stream::do_scanf): Don't set error when reaching end of stream.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 02 Aug 2022 18:46:24 +0200
parents 5386fd4af64c
children c90718a28a3c e8a46f801825
files libinterp/corefcn/oct-stream.cc
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc	Fri Jul 29 20:53:14 2022 -0700
+++ b/libinterp/corefcn/oct-stream.cc	Tue Aug 02 18:46:24 2022 +0200
@@ -4996,7 +4996,7 @@
 
                     // If it looks like we have a matching failure, then
                     // reset the failbit in the stream state.
-                    if (is.rdstate () & std::ios::failbit)
+                    if (! is.eof () && is.rdstate () & std::ios::failbit)
                       {
                         error (who, "format failed to match");
                         is.clear (is.rdstate () & (~std::ios::failbit));