diff options
author | dcs <dcs@FreeBSD.org> | 1999-02-04 17:06:46 +0000 |
---|---|---|
committer | dcs <dcs@FreeBSD.org> | 1999-02-04 17:06:46 +0000 |
commit | 755c131c9f9186c9e5988ecd80463ebaf5736541 (patch) | |
tree | 58e08046a8f6ce1037ca20ede61682ebb6aa8c16 /sys/boot/common/interp.c | |
parent | 60ace12c39d160ce8ffa553ba201f1f6ea1edc97 (diff) | |
download | FreeBSD-src-755c131c9f9186c9e5988ecd80463ebaf5736541.zip FreeBSD-src-755c131c9f9186c9e5988ecd80463ebaf5736541.tar.gz |
Make use of prototypes to silence warnings.
Change include() so it will be able to load files with forth code,
instead of just builtins. Remove #@- from the include section of the
help file, since they don't work in the new version of include, unless
BOOT_FORTH is not defined.
Change bf_run() so it will return the result returned by ficlExec(). Also,
make bf_run() push "interpret" to be executed by ficlExec(), since ficlExec()
doesn't do it by itself. (Things worked previously because nothing
recursed through ficlExec() by the way of bf_run()).
Change/extend comments on builtin behavior.
Search for "interpret" at the end of bf_init(), so /boot/boot.4th can
provide it's own version.
Remove dead code.
Diffstat (limited to 'sys/boot/common/interp.c')
-rw-r--r-- | sys/boot/common/interp.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/sys/boot/common/interp.c b/sys/boot/common/interp.c index 09240a8..276548c 100644 --- a/sys/boot/common/interp.c +++ b/sys/boot/common/interp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: interp.c,v 1.12 1999/01/15 00:31:45 abial Exp $ + * $Id: interp.c,v 1.13 1999/01/22 23:50:13 msmith Exp $ */ /* * Simple commandline interpreter, toplevel and misc. @@ -170,9 +170,15 @@ include(char *filename) { struct includeline *script, *se, *sp; char input[256]; /* big enough? */ +#ifdef BOOT_FORTH + int res; + char *cp; + int fd, line; +#else int argc,res; char **argv, *cp; int fd, flags, line; +#endif if (((fd = open(filename, O_RDONLY)) == -1)) { sprintf(command_errbuf,"can't open '%s': %s\n", filename, strerror(errno)); @@ -187,6 +193,9 @@ include(char *filename) while (fgetstr(input, sizeof(input), fd) > 0) { line++; +#ifdef BOOT_FORTH + cp = input; +#else flags = 0; /* Discard comments */ if (input[0] == '#') @@ -202,11 +211,14 @@ include(char *filename) cp++; flags |= SL_IGNOREERR; } +#endif /* Allocate script line structure and copy line, flags */ sp = malloc(sizeof(struct includeline) + strlen(cp) + 1); sp->text = (char *)sp + sizeof(struct includeline); strcpy(sp->text, cp); +#ifndef BOOT_FORTH sp->flags = flags; +#endif sp->line = line; sp->next = NULL; @@ -222,10 +234,21 @@ include(char *filename) /* * Execute the script */ +#ifndef BOOT_FORTH argv = NULL; +#endif res = CMD_OK; for (sp = script; sp != NULL; sp = sp->next) { +#ifdef BOOT_FORTH + res = bf_run(sp->text); + if (res != VM_OUTOFTEXT) { + sprintf(command_errbuf, "Error while including %s:\n%s", filename, sp->text); + res = CMD_ERROR; + break; + } else + res = CMD_OK; +#else /* print if not being quiet */ if (!(sp->flags & SL_QUIET)) { prompt(); @@ -249,9 +272,12 @@ include(char *filename) res=CMD_ERROR; break; } +#endif } +#ifndef BOOT_FORTH if (argv != NULL) free(argv); +#endif while(script != NULL) { se = script; script = script->next; |