mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2025-02-07 04:30:31 +00:00
strtoul: don't try to parse initial '0x' as hex prefix unless base is 0 or 16.
In other bases, the 'x' either ends parsing of the number string or (in base 34 and larger) is a digit. Also, ensure only ASCII characters (with high bit clear) are accepted in all situations.
This commit is contained in:
parent
27fc6836cc
commit
7a20f5f71d
20
stdlib.asm
20
stdlib.asm
@ -858,23 +858,23 @@ db1a lda base if the base is zero then
|
||||
lda [str] if the first char is 0 then
|
||||
and #$00FF
|
||||
cmp #'0'
|
||||
bne db2
|
||||
bne cn1
|
||||
lda #8 assume base 8
|
||||
sta base
|
||||
ldy #1 if the second char is 'X' or 'x' then
|
||||
lda [str],Y
|
||||
and #$005F
|
||||
and #$00DF
|
||||
cmp #'X'
|
||||
bne db2
|
||||
bne cn1
|
||||
asl base base 16
|
||||
db2 lda [str] if the first two chars are 0x or 0X then
|
||||
and #$5F7F
|
||||
bra db3
|
||||
db2 cmp #16 if the base is 16 then
|
||||
bne cn1
|
||||
lda [str] if the first two chars are 0x or 0X then
|
||||
and #$DFFF
|
||||
cmp #'X0'
|
||||
bne cn1
|
||||
add4 str,#2 skip them
|
||||
lda base make sure the base is 16
|
||||
cmp #16
|
||||
bne returnERANGE
|
||||
db3 add4 str,#2 skip them
|
||||
;
|
||||
; Convert the number
|
||||
;
|
||||
@ -884,7 +884,7 @@ cn1 lda [str] get a (possible) digit
|
||||
blt cn5
|
||||
cmp #'9'+1 branch if it is a numeric digit
|
||||
blt cn2
|
||||
and #$005F convert lowercase to uppercase
|
||||
and #$00DF convert lowercase to uppercase
|
||||
cmp #'A' branch if it is not a digit
|
||||
blt cn5
|
||||
cmp #'Z'+1 branch if it is not a digit
|
||||
|
Loading…
x
Reference in New Issue
Block a user