Skip to content

Commit

Permalink
enable command line to properly process quoted string arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
beckadamtheinventor committed Dec 9, 2023
1 parent 227d587 commit 92ce9b8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
8 changes: 6 additions & 2 deletions src/compatibility/_ResetAndBuildVAT.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ _ResetAndBuildVAT:
call _BuildVAT
ld hl,(ti.pTemp)
push hl
ld hl,'A' shl 8
ld hl,'A' shl 8 ; letter variables
ld (ti.OP1),hl
.realvariableloop:
ld hl,9
call _CreateVar.entryOP1
ld a,(ti.OP1+1)
cp a,'Z'
cp a,'Z'+1 ; create up until theta (letter after Z in TI-BASIC tokens)
jr z,.donereals
inc a
ld (ti.OP1+1),a
jr .realvariableloop
.donereals:
ld hl,$72 shl 8 ; Ans
ld (ti.OP1),hl
ld hl,9
call _CreateVar.entryOP1 ; create Ans variable
ld hl,(ti.pTemp)
ld (ti.OPBase),hl
pop hl
Expand Down
53 changes: 39 additions & 14 deletions src/data/adrive/src/fs/bin/cmd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ cmd_exit:
pop ix
ret

; input hl pointer to line
; output hl pointer to character following EOL, replacing the EOL with NULL
cmd_terminate_line:
xor a,a
ld (ix-20),a
Expand All @@ -452,6 +454,8 @@ cmd_terminate_line:
jr z,.eol
cp a,$A
jr z,.eol
; cp a,'>'
; jr z,.eol
inc hl
cp a,$5C ;backslash
jr nz,.loop
Expand All @@ -468,6 +472,8 @@ cmd_get_arguments.inc_twice:
inc hl
cmd_get_arguments.loop:
inc hl
; input hl pointer to first char of argument string
; output hl pointer to character following EOL, replacing spaces (outside of quotes) with NULL
cmd_get_arguments:
ld a,(hl)
or a,a
Expand All @@ -476,34 +482,53 @@ cmd_get_arguments:
ret z
cp a,$A
ret z
cp a,$5C ;backslash
cp a,'"'
jr z,.process_quotes
cp a,$27 ; single quote
jr z,.process_quotes
cp a,$5C ; backslash
jr z,.inc_twice
cp a,' '
jr nz,.loop
ld (hl),0
.done:
inc hl
ret

cmd_config_data_struct:
db "BTBG", 0
dl bos.lcd_text_bg
db "BTFG", 0
dl bos.lcd_text_fg
db "BTFG2", 0
dl bos.lcd_text_fg2
db "BBGC", 0
dl bos.lcd_bg_color
db 0
.process_quotes:
ld c,a
dec hl
.process_quotes_loop:
inc hl
ld a,(hl)
or a,a
jr z,.done
cp a,$5C ; backslash
jr z,.process_quotes_loop ; handle escaped characters
cp a,c
jr nz,.process_quotes_loop
jr .loop

; cmd_config_data_struct:
; db "BTBG", 0
; dl bos.lcd_text_bg
; db "BTFG", 0
; dl bos.lcd_text_fg
; db "BTFG2", 0
; dl bos.lcd_text_fg2
; db "BBGC", 0
; dl bos.lcd_bg_color
; db 0

cmd_help_info:
db " cmd cmds",$A,$9,"run command(s) but exit if one returns an error",$A
db " cmd -a cmds",$A,$9,"run all commands(s) regardless of error codes",$A
db " cmd -i cmds",$A,$9,"run commands(s), ignoring all errors",$A
db " cmd -x file",$A,$9,"run a command file",$A,0

str_system_path:
db "/bin/"
.len:=$-.
; str_system_path:
; db "/bin/"
; .len:=$-.
str_ProgramFailedWithCode:
db "Error Code ",0
str_CouldNotLocateExecutable:
Expand Down

0 comments on commit 92ce9b8

Please sign in to comment.