scanf: if %c gets some characters but < field width, it's a matching failure.

EOF should not be returned in this case.

I think it shouldn't actually write anything to the destination in this case, but it currently does. That problem remains unfixed for the moment; addressing it would require us to have our own internal buffer.
This commit is contained in:
Stephen Heumann 2021-02-09 16:00:25 -06:00
parent 6626aad7f0
commit cfc3fd3468
1 changed files with 10 additions and 3 deletions

View File

@ -4708,20 +4708,25 @@ lb1 lda 13,S move the critical values
using ~scanfCommon
arg equ 11 argument
stz didOne no characters scanned from the stream
lda ~scanWidth if ~scanWidth == 0 then
bne lb1
inc ~scanWidth ~scanWidth = 1
lb1 jsl ~getchar get the character
cmp #EOF if at EOF then
bne lb1b
ldx didOne if no characters read then
bne lb1a
sta ~eofFound ~eofFound = EOF
lda ~suppress if input is not suppressed then
sta ~eofFound ~eofFound = EOF
lb1a lda ~suppress if input is not suppressed then
bne lb3
dec ~assignments no assignment made
bra lb3 bail out
lb1a ldx ~suppress if input is not suppressed then
lb1b ldx #1
stx didOne
ldx ~suppress if input is not suppressed then
bne lb2
short M save the value
sta [arg]
@ -4734,6 +4739,8 @@ lb3 lda ~suppress if input is not suppressed then
ldy #2
jsr ~RemoveWord remove the parameter from the stack
lb4 rts
didOne ds 2 non-zero if we have scanned a character
end
****************************************************************