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

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

[Octave-bug-tracker] [bug #63462] sscanf reports incorrect number of out


From: anonymous
Subject: [Octave-bug-tracker] [bug #63462] sscanf reports incorrect number of output values.
Date: Thu, 8 Dec 2022 05:18:14 -0500 (EST)

Follow-up Comment #16, bug #63462 (project octave):

I don't know exactly why, but it seems that the following patch fixes the
issue:

diff -r b69d89906ae9 libinterp/corefcn/oct-stream.cc
--- a/libinterp/corefcn/oct-stream.cc   Sat Dec 03 14:45:33 2022 -0500
+++ b/libinterp/corefcn/oct-stream.cc   Thu Dec 08 11:10:52 2022 +0100
@@ -5314,7 +5314,7 @@
           {
             double tmp;
 
-            if (octave_scan (is, *elt, &tmp))
+            if (octave_scan (is, *elt, &tmp).good())
               {
                 if (! discard)
                   retval = tmp;


When applying the patch, I get this output:

[a,b,c,d,cnt]=sscanf("1 abcdefg 1.5\n","%d %s %g %g","C")
a = 1
b = abcdefg
c = 1.5000
d = [](0x0)
cnt = 3


(file #54069)

    _______________________________________________________

Additional Item Attachment:

File name: oct-stream.patch               Size:0 KB
    <https://file.savannah.gnu.org/file/oct-stream.patch?file_id=54069>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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