fix issue w/include causing rre to exit in interactive mode

FossilOrigin-Name: adfe6121a489741204ff86b16d6236ee66caef8d1fab9c48c196698ad27568b4
This commit is contained in:
crc 2017-11-28 02:20:59 +00:00
parent eecd8d7ebf
commit b511cfea0b
3 changed files with 10 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -375,7 +375,7 @@ void execute(int cell) {
switch (opcode) {
case IO_TTY_PUTC: putc(stack_pop(), stdout); fflush(stdout); break;
case IO_TTY_GETC: stack_push(getc(stdin)); break;
case -9999: include_file(string_extract(stack_pop())); break;
case -9999: include_file(string_extract(stack_pop())); break;
case IO_FS_OPEN: ioOpenFile(); break;
case IO_FS_CLOSE: ioCloseFile(); break;
case IO_FS_READ: stack_push(ioReadFile()); break;
@ -833,9 +833,11 @@ int main(int argc, char **argv) {
if (argc > 1) {
if (strcmp(argv[1], "-i") == 0) {
execute(d_xt_for("listen", Dictionary));
execute(d_xt_for("banner", Dictionary));
while (1) execute(d_xt_for("listen", Dictionary));
} else if (strcmp(argv[1], "-ic") == 0) {
execute(d_xt_for("listen-cbreak", Dictionary));
execute(d_xt_for("banner", Dictionary));
while (1) execute(d_xt_for("listen-cbreak", Dictionary));
} else {
include_file(argv[1]);
}

View file

@ -336,8 +336,6 @@ once for each line in a file. This makes some things trivial. E.g., a simple
'CBreak var
:version (-) @Version #100 /mod putn $. putc putn ;
:banner (-) 'RETRO_12_(rx- puts version $) putc nl
EOM putn '_MAX,_TIB_@_1025,_Heap_@_ puts here putn nl ;
:eol? (c-f) [ ASCII:CR eq? ] [ ASCII:LF eq? ] [ ASCII:SPACE eq? ] tri or or ;
:valid? (s-sf) dup s:length n:-zero? ;
:ok (-) compiling? [ nl 'Ok_ puts ] -if ;
@ -347,9 +345,11 @@ once for each line in a file. This makes some things trivial. E.g., a simple
[ getc dup buffer:add check-eof check-bs eol? ] until
buffer:start s:chop ] buffer:preserve ;
---reveal---
:banner (-) 'RETRO_12_(rx- puts version $) putc nl
EOM putn '_MAX,_TIB_@_1025,_Heap_@_ puts here putn nl ;
:bye (-) @CBreak [ 'stty_-cbreak unix:system ] if #0 unix:exit ;
:listen (-)
banner ok repeat gets valid? [ interpret ok ] [ drop ] choose again ;
ok repeat gets valid? [ interpret ok ] [ drop ] choose again ;
:listen-cbreak (-)
&CBreak v:on 'stty_cbreak unix:system listen ;
}}