octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63383] Error in sscanf in special cases when


From: Rik
Subject: [Octave-bug-tracker] [bug #63383] Error in sscanf in special cases when '%f' conversion is used
Date: Sat, 19 Nov 2022 20:33:35 -0500 (EST)

Follow-up Comment #3, bug #63383 (project octave):

the scanf parsing is complex and distributed across functions in libinterp and
in liboctave.  Using the debugger, it appears that reading a double in
liboctave is correctly setting the fail bit on the input stream.  However,
back in libinterp the test for the fail condition is specifically disabled if
the failure occurs at the EOF.


if (! is.eof () && is.rdstate () & std::ios::failbit)


Removing the eof() test with this patch makes things work for this bug
report.


diff --git a/libinterp/corefcn/oct-stream.cc
b/libinterp/corefcn/oct-stream.cc
--- a/libinterp/corefcn/oct-stream.cc
+++ b/libinterp/corefcn/oct-stream.cc
@@ -5042,7 +5042,8 @@ namespace octave
 
                     // If it looks like we have a matching failure, then
                     // reset the failbit in the stream state.
-                    if (! is.eof () && is.rdstate () & std::ios::failbit)
+                    //if (! is.eof () && is.rdstate () & std::ios::failbit)
+                    if (is.rdstate () & std::ios::failbit)
                       {
                         error (who, "format failed to match");
                         is.clear (is.rdstate () & (~std::ios::failbit));


But, this then causes a regression BIST to fail for bug #62723.

Overall, this is probably not too difficult to fix.  But, I think it means
re-visiting bug #62723 and finding a different solution there.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63383>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]