[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #56200] sscanf fourth output might be incorrec
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #56200] sscanf fourth output might be incorrect for decimal fields |
Date: |
Thu, 25 Apr 2019 02:23:46 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 |
Update of bug #56200 (project octave):
Category: None => Octave Function
Item Group: None => Incorrect Result
Status: None => Confirmed
Operating System: Microsoft Windows => Any
_______________________________________________________
Follow-up Comment #1:
Confirmed. It seems to be caused by the combination of all 3 of
1. the %d conversion specifier,
2. a field width on the %d conversion, and
3. the adjacent non-digit, non-space character
For example,
>> [val, count, errmsg, nextpos] = sscanf ('3a', '%6d', 1)
val = 3
count = 1
errmsg =
nextpos = 3
As you showed, if %f or %g is used instead, it works correctly.
>> [val, count, errmsg, nextpos] = sscanf ('3a', '%6g', 1)
val = 3
count = 1
errmsg =
nextpos = 2
If the field width is removed, it also works correctly
>> [val, count, errmsg, nextpos] = sscanf ('3a', '%d', 1)
val = 3
count = 1
errmsg =
nextpos = 2
And if the integer is followed by a space instead of an alphabetic or
punctuation character, it works correctly
>> [val, count, errmsg, nextpos] = sscanf ('3 a', '%6d', 1)
val = 3
count = 1
errmsg =
nextpos = 2
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?56200>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/