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

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

[Octave-bug-tracker] [bug #56200] sscanf fourth output might be incorrec


From: Felipe G. Nievinski
Subject: [Octave-bug-tracker] [bug #56200] sscanf fourth output might be incorrect for decimal fields
Date: Tue, 23 Apr 2019 11:37:07 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?56200>

                 Summary: sscanf fourth output might be incorrect for decimal
fields
                 Project: GNU Octave
            Submitted by: fgnievinski
            Submitted on: Tue 23 Apr 2019 03:37:05 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 5.1.0
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

In Matlab, doing:

string = '1  9G02';
template = '%1d%3d';
size = 2;
[val, count, errmsg, nextpos] = sscanf (string, template, size)
display(['-' string(nextpos:end) '-'])

I get:

val =
     1
     9
count =
     2
errmsg =
  0×0 empty char array
nextpos =
     5
-G02-

Whereas in Octave 5, I get a different result for output nextpos:

   val =

       1
       9

    count =  2
    errmsg =
    nextpos =  7
-2-

The only way to get the correct result for nextpos in Octave is replacing the
last decimal field specification for a float:

string = '1  9G02';
template = '%1d%3f';
size = 2;
[val, count, errmsg, nextpos] = sscanf (string, template, size)
display(['-' string(nextpos:end) '-'])

    val =

       1
       9

    count =  2
    errmsg =
    nextpos =  5
-G02-

I seems the problem is caused by the adjacent literal character "G".






    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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