mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-09-29 17:55:17 +00:00
scanf: a sign and/or 0x prefix with no following digits should be a matching failure.
This applies to + or - signs for 'd' or 'i' conversions, and to '0x' or '0X' prefixes for 'i' and 'x' conversions. (The new support for signs on u/o/x conversions did not have the problem.) These cases were treated as if they successfully matched a number, but now they are correctly treated as a failure, causing no assignment to be done and causing the function to return without processing any further directives. (Incidentally, the handling of '0x' without following digits is something that differs in modern C libraries: macOS libc, glibc, and musl are all different. Our new behavior should match that of musl, which I believe is what is correct under the C standards.)
This commit is contained in:
parent
3ef9687b7e
commit
539707344a
@ -4787,7 +4787,6 @@ ef1 tax {...back to skipping whitespace}
|
|||||||
bne sg2
|
bne sg2
|
||||||
inc minus
|
inc minus
|
||||||
sg1 jsl ~getchar
|
sg1 jsl ~getchar
|
||||||
inc read
|
|
||||||
sg2 ldx based if base 8, 16 are allowed then
|
sg2 ldx based if base 8, 16 are allowed then
|
||||||
beq lb2
|
beq lb2
|
||||||
cmp #'0' if the digit is '0' then
|
cmp #'0' if the digit is '0' then
|
||||||
@ -4805,6 +4804,7 @@ lb1a jsl ~getchar
|
|||||||
cmp #'x'
|
cmp #'x'
|
||||||
bne lb2
|
bne lb2
|
||||||
lb1b asl base use base 16
|
lb1b asl base use base 16
|
||||||
|
stz read '0x' alone should not match
|
||||||
dec ~scanWidth get the next character
|
dec ~scanWidth get the next character
|
||||||
jeq lb4a
|
jeq lb4a
|
||||||
bpl lb1c
|
bpl lb1c
|
||||||
@ -4903,7 +4903,7 @@ val ds 8 value
|
|||||||
base dc i2'10' number base
|
base dc i2'10' number base
|
||||||
based ds 2 based conversion?
|
based ds 2 based conversion?
|
||||||
minus ds 2 is the value negative?
|
minus ds 2 is the value negative?
|
||||||
read ds 2 # chars read
|
read ds 2 # of digits read
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
@ -5228,7 +5228,8 @@ hx1 jsl ~getchar
|
|||||||
beq hx1a
|
beq hx1a
|
||||||
cmp #'X'
|
cmp #'X'
|
||||||
bne hx2
|
bne hx2
|
||||||
hx1a dec ~scanWidth accept the character
|
hx1a stz read ('0x' alone should not match)
|
||||||
|
dec ~scanWidth accept the character
|
||||||
jeq lb4a
|
jeq lb4a
|
||||||
bpl hx3
|
bpl hx3
|
||||||
stz ~scanWidth
|
stz ~scanWidth
|
||||||
@ -5376,7 +5377,7 @@ val ds 8 value
|
|||||||
base dc i2'10' number base
|
base dc i2'10' number base
|
||||||
based ds 2 based conversion?
|
based ds 2 based conversion?
|
||||||
minus ds 2 is there a minus sign?
|
minus ds 2 is there a minus sign?
|
||||||
read ds 2 # chars read
|
read ds 2 # of digits read
|
||||||
end
|
end
|
||||||
|
|
||||||
****************************************************************
|
****************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user