Closed nyankers closed 2 years ago
Definitely a bug.
Should be fixed by 8acd15f96c60812b897b64a7464e025e96fa33b0.
That fixes the int-related issues, but I noticed the float issues are a bit more extensive, e.g. even after the fix, it'll accept (float) "."
as 0.0
. This fix also breaks (float) "-.50"
whereas (float) ".50"
works.
(The same code is used for both sscanf()
and (float)
.)
I'll submit a push request with a possible solution, unless (float) ".50"
and (float) "-.50"
are unintentional behavior too, in which case it'll need further adjustments (though they're accepted as LPC, so I assume they should be accepted here too).
I used a different fix, 4aa22ce24d1666e7f44264deb36cd36d1ed66a43.
Ah, I didn't realize 5.
was also an acceptable LPC float literal, but it apparently is (and so my suggestion would have broken otherwise valid LPC code). Thanks!
I don't see anything this version breaks. If I find out later, I'll of course let you know. ^^
Hi, I'm not sure if this is a bug or if it's in fact an intended nuance of
sscanf()
.Should
sscanf("-", "%d", x)
treat it as a match (return1
) and store0
inx
?I also see similar behavior with
"%f"
.Easily tested in cloud server via
code ({ sscanf("-", "%d", a), a })
.