add shifting of argument list in interpreter mode
This commit is contained in:
parent
1d930672bc
commit
559eb400a8
14
startup.4th
14
startup.4th
|
|
@ -2384,6 +2384,9 @@ SYSTEM DEFINITIONS
|
||||||
\ immediately following the NULL-terminated array of argument pointers
|
\ immediately following the NULL-terminated array of argument pointers
|
||||||
ARGV ARGC 1+ CELLS+ CONSTANT ENVIRON
|
ARGV ARGC 1+ CELLS+ CONSTANT ENVIRON
|
||||||
|
|
||||||
|
VARIABLE ARGV-SHIFT
|
||||||
|
0 ARGV-SHIFT !
|
||||||
|
|
||||||
FORTH DEFINITIONS
|
FORTH DEFINITIONS
|
||||||
|
|
||||||
\ Convert a C string to a FORTH string by counting the characters
|
\ Convert a C string to a FORTH string by counting the characters
|
||||||
|
|
@ -2400,10 +2403,16 @@ FORTH DEFINITIONS
|
||||||
2DROP CELL+
|
2DROP CELL+
|
||||||
REPEAT ▪ NIP ▪ 2RDROP ;
|
REPEAT ▪ NIP ▪ 2RDROP ;
|
||||||
|
|
||||||
|
\ Return ARGC decremented by ARGV-SHIFT, but not less than zero
|
||||||
|
: ARGC ( -- u ) ARGC DUP ARGV-SHIFT @ UMIN - ;
|
||||||
|
|
||||||
\ Return the string value of the numbered command-line argument
|
\ Return the string value of the numbered command-line argument
|
||||||
\ Argument 0 is (normally) the pathname of the current program
|
\ Argument 0 is (normally) the pathname of the current program
|
||||||
: ARGV ( u -- c-addr u )
|
: ARGV ( u -- c-addr u )
|
||||||
DUP ARGC U>= IF DROP 0 0 ELSE ARGV SWAP CELLS+ @ CSTRING THEN ;
|
DUP ARGC U>= IF DROP 0 0 ELSE ARGV SWAP ARGV-SHIFT @ + CELLS+ @ CSTRING THEN ;
|
||||||
|
|
||||||
|
: SHIFT-ARGV ( -- c-addr u )
|
||||||
|
0 ARGV 1 ARGV-SHIFT +! ;
|
||||||
|
|
||||||
UTILITY DEFINITIONS
|
UTILITY DEFINITIONS
|
||||||
|
|
||||||
|
|
@ -3018,7 +3027,8 @@ SYSTEM DEFINITIONS
|
||||||
{
|
{
|
||||||
ONLY FORTH DEFINITIONS
|
ONLY FORTH DEFINITIONS
|
||||||
ARGC 2 U>= IF
|
ARGC 2 U>= IF
|
||||||
1 ARGV [[ ' INCLUDED ]] CATCH
|
"SHIFT-ARGV SCONSTANT INTERPRETER" EVALUATE
|
||||||
|
0 ARGV [[ ' INCLUDED ]] CATCH
|
||||||
DUP EXCP-QUIT = IF
|
DUP EXCP-QUIT = IF
|
||||||
DROP 2DROP QUIT
|
DROP 2DROP QUIT
|
||||||
ELSE ?DUP IF
|
ELSE ?DUP IF
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue