From 18ee60a57616434a5c49b4d75f07f57d63d1db60 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Wed, 14 Jun 2000 19:37:00 +0000 Subject: [PATCH] Remove the setting of sourceid from bf_vm(), as bf_vm() really has no clue. Set sourceid to 0 when booting, which is the correct setting for stdin. Set sourceid to an arbitrary fd when include'ing, preserving and restoring the previous sourceid. This is possibly broken(), as 0 is a valid fd. Maybe we should +1 to this value. This fixes the version problem widely reported. --- sys/boot/common/interp.c | 8 +++++++- sys/boot/common/interp_forth.c | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/boot/common/interp.c b/sys/boot/common/interp.c index e93e35ae52e8..880910bae094 100644 --- a/sys/boot/common/interp.c +++ b/sys/boot/common/interp.c @@ -122,6 +122,7 @@ interact(void) prompt(); ngets(input, sizeof(input)); #ifdef BOOT_FORTH + bf_vm->sourceID.i = 0; bf_run(input); #else if (!parse(&argc, &argv, input)) { @@ -189,7 +190,7 @@ include(char *filename) #ifdef BOOT_FORTH int res; char *cp; - int fd, line; + int prevsrcid, fd, line; #else int argc,res; char **argv, *cp; @@ -252,6 +253,9 @@ include(char *filename) */ #ifndef BOOT_FORTH argv = NULL; +#else + prevsrcid = bf_vm->sourceID.i; + bf_vm->sourceID.i = fd; #endif res = CMD_OK; for (sp = script; sp != NULL; sp = sp->next) { @@ -293,6 +297,8 @@ include(char *filename) #ifndef BOOT_FORTH if (argv != NULL) free(argv); +#else + bf_vm->sourceID.i = prevsrcid; #endif while(script != NULL) { se = script; diff --git a/sys/boot/common/interp_forth.c b/sys/boot/common/interp_forth.c index fa7925a7aa74..1cf60c437960 100644 --- a/sys/boot/common/interp_forth.c +++ b/sys/boot/common/interp_forth.c @@ -273,12 +273,8 @@ int bf_run(char *line) { int result; - CELL id; - id = bf_vm->sourceID; - bf_vm->sourceID.i = -1; result = ficlExec(bf_vm, line); - bf_vm->sourceID = id; DEBUG("ficlExec '%s' = %d", line, result); switch (result) {