diff options
author | msmith <msmith@FreeBSD.org> | 1998-11-06 03:45:36 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-11-06 03:45:36 +0000 |
commit | 8602321e78d6bbdd78dda945691d51b45d7d8293 (patch) | |
tree | 1614ac48ba70bc350ee9d65c251a60e30f41db29 /sys/boot | |
parent | fe3661b3bc5937f3e510191d4cf505f04084c411 (diff) | |
download | FreeBSD-src-8602321e78d6bbdd78dda945691d51b45d7d8293.zip FreeBSD-src-8602321e78d6bbdd78dda945691d51b45d7d8293.tar.gz |
Don't use the poxy vmGetString interface (who uses counted strings these
days?), get the input buffer ourselves. Add some debugging code.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/common/interp_forth.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/sys/boot/common/interp_forth.c b/sys/boot/common/interp_forth.c index 36d4838..94cc9fe 100644 --- a/sys/boot/common/interp_forth.c +++ b/sys/boot/common/interp_forth.c @@ -23,13 +23,21 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: interp_forth.c,v 1.2 1998/11/04 03:41:09 msmith Exp $ + * $Id: interp_forth.c,v 1.3 1998/11/05 08:39:38 jkh Exp $ */ #include <stand.h> #include "bootstrap.h" #include "ficl.h" +#define BFORTH_DEBUG + +#ifdef BFORTH_DEBUG +# define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __FUNCTION__ , ## args) +#else +# define DEBUG(fmt, args...) +#endif + /* * BootForth Interface to Ficl Forth interpreter. */ @@ -43,10 +51,10 @@ static FICL_VM *bf_vm; static void bf_command(FICL_VM *vm) { + char *name, *line, *tail, *cp; + int len; struct bootblk_command **cmdp; bootblk_cmd_t *cmd; - char *name, *line; - FICL_STRING *tail = (FICL_STRING *)vm->pad; int argc, result; char **argv; @@ -54,6 +62,7 @@ bf_command(FICL_VM *vm) name = vm->runningWord->name; /* Find our command structure */ + cmd == NULL; SET_FOREACH(cmdp, Xcommand_set) { if (((*cmdp)->c_name != NULL) && !strcmp(name, (*cmdp)->c_name)) cmd = (*cmdp)->c_fn; @@ -62,11 +71,16 @@ bf_command(FICL_VM *vm) panic("callout for unknown command '%s'", name); /* Get remainder of invocation */ - vmGetString(vm, tail, '\n'); + tail = vmGetInBuf(vm); + for (cp = tail, len = 0; *cp != 0 && *cp != '\n'; cp++, len++) + ; + + line = malloc(strlen(name) + len + 2); + strcpy(line, name); + if (len > 0) + strncat(line, tail, len); + DEBUG("cmd '%s'", line); - /* XXX This is grostic */ - line = malloc(strlen(name) + strlen(tail->text) + 2); - sprintf(line, "%s %s", name, tail->text); command_errmsg = command_errbuf; command_errbuf[0] = 0; if (!parse(&argc, &argv, line)) { @@ -109,6 +123,8 @@ bf_run(char *line) int result; result = ficlExec(bf_vm, line); + DEBUG("ficlExec '%s' = %d", line, result); + if (result == VM_USEREXIT) panic("interpreter exit"); } |