mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2025-02-07 04:30:31 +00:00
Detect invalid base values in strtol and strtoul.
They will now return 0 and set errno to EINVAL if an invalid base value (anything other than 0 or 2..36) is detected. This behavior is required by POSIX. It's not required by the C standards (which leave the behavior in this case undefined), but it seems reasonable to do.
This commit is contained in:
parent
e5360c9605
commit
717cf99071
@ -982,12 +982,17 @@ db1c lda base if the base is zero then
|
||||
asl base base 16
|
||||
bra db3
|
||||
db2 cmp #16 if the base is 16 then
|
||||
bne cn1
|
||||
bne db4
|
||||
lda [str] if the first two chars are 0x or 0X then
|
||||
and #$DFFF
|
||||
cmp #'X0'
|
||||
bne cn1
|
||||
db3 add4 str,#2 skip them
|
||||
bra cn1
|
||||
db4 cmp #37 check for invalid base value
|
||||
bge cn6
|
||||
dec a
|
||||
beq cn6
|
||||
;
|
||||
; Convert the number
|
||||
;
|
||||
@ -1041,7 +1046,7 @@ cn4 inc4 str next char
|
||||
|
||||
cn5 lda foundOne if no digits were found, flag the error
|
||||
bne rt1
|
||||
lda #EINVAL
|
||||
cn6 lda #EINVAL
|
||||
sta >errno
|
||||
bra rt2a
|
||||
;
|
||||
|
Loading…
x
Reference in New Issue
Block a user