Make strtol/strtoul return LONG_MIN/LONG_MAX/ULONG_MAX for out-of-range values.

This fixes #10.

There are still issues with the end pointer value generated in error cases.
This commit is contained in:
Stephen Heumann 2018-03-13 22:11:40 -05:00
parent 7abdfc9beb
commit 6e97906678
1 changed files with 12 additions and 2 deletions

View File

@ -748,6 +748,14 @@ cn3 ph4 str save the starting string
;
lda #ERANGE errno = ERANGE
sta >errno
ldx #$7FFF return value = LONG_MAX
ldy #$FFFF
lda negative if negative then
beq ov1
inx return value = LONG_MIN
iny
ov1 sty val
stx val+2
lda ptr if ptr <> NULL then
ora ptr+2
bne rt1
@ -920,7 +928,9 @@ cn5 lda foundOne if no digits were found, flag the error
returnERANGE anop
lda #ERANGE errno = ERANGE
sta >errno
bra rt2 skip setting ptr
ldx #$FFFF return value = ULONG_MAX
txy
bra rt3 skip setting ptr
;
; return the results
;
@ -934,7 +944,7 @@ rt1 lda ptr if ptr is non-null then
sta [ptr],Y
rt2 ldx val+2 get the value
ldy val
lda rtl fix the stack
rt3 lda rtl fix the stack
sta base-1
lda rtl+1
sta base