1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-24 14:28:06 +11:00

(parsed): fix crash on parsing non-decimal staring with '-'

The address returned in the error condition would be off by one.
This commit is contained in:
Virgil Dupras 2020-05-25 21:15:07 -04:00
parent 2d17b4e8ec
commit d8a6456206
4 changed files with 7 additions and 10 deletions

View File

@ -7,6 +7,7 @@
: MIN ( n n - n ) 2DUP > IF SWAP THEN DROP ;
: MAX ( n n - n ) 2DUP < IF SWAP THEN DROP ;
: NIP SWAP DROP ; : TUCK SWAP OVER ;
: -^ SWAP - ;
: C@+ ( a -- a+1 c ) DUP C@ SWAP 1+ SWAP ;
: C!+ ( c a -- a+1 ) TUCK C! 1+ ;
: C@- ( a -- a-1 c ) DUP C@ SWAP 1- SWAP ;

15
blk/357
View File

@ -1,11 +1,8 @@
: _ ( a+1 len -- n f )
OVER C@ ( a len c )
'-' = IF
1- SWAP 1+ SWAP ( a+1 len-1 ) _ 0 ROT ( f 0 n )
- SWAP EXIT ( 0-n f )
THEN ( a len )
0 SWAP ( len ) 0 DO ( a r )
: (parsed) ( a -- n f )
C@+ OVER C@ 0 ( a len firstchar startat )
SWAP '-' = IF 1+ THEN ( a len startat )
0 ROT ROT ( len ) ( startat ) DO ( a r )
OVER I + C@ ( a r c ) _pdacc ( a r f )
IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
NIP 1 ;
: (parsed) ( a -- n f ) C@+ ( a+1 l ) _ ;
( negate if needed )
SWAP C@ '-' = IF 0 -^ THEN 1 ( r 1 ) ;

View File

@ -3,7 +3,6 @@
DUP C@ 128 OR SWAP C! ;
: IMMED? 1- C@ 0x80 AND ;
: +! TUCK @ + SWAP ! ;
: -^ SWAP - ;
: / /MOD NIP ;
: MOD /MOD DROP ;
: ALLOT HERE +! ;

Binary file not shown.