diff --git a/eval.c b/eval.c index 01e2c44..0a99600 100644 --- a/eval.c +++ b/eval.c @@ -771,7 +771,7 @@ int setvar(int f, int n) /* first get the variable to set.. */ if (clexec == FALSE) { - status = mlreply( "Variable to set: ", var, sizeof var) ; + status = getstring( "Variable to set: ", var, sizeof var, nlc) ; if (status != TRUE) return status; } else { /* macro line argument */ @@ -889,10 +889,8 @@ fvar: var[4] = 0; if (strcmp(&var[1], "ind") == 0) { /* grab token, and eval it */ - gettoken( var, size) ; - strncpy( var, getval( var), size - 1) ; - var[ size - 1] = '\0' ; - goto fvar; + if( TRUE == gettokval( var, size)) + goto fvar ; } } diff --git a/exec.c b/exec.c index dec8f3b..601baac 100644 --- a/exec.c +++ b/exec.c @@ -286,6 +286,23 @@ void gettoken( char *tok, int maxtoksize) { execstr = token( execstr, tok, maxtoksize) ; } +boolean gettokval( char *tok, int size) { + char *tmpbuf ; + + tmpbuf = malloc( size) ; + if( tmpbuf == NULL) + return FALSE ; + + /* grab token and advance past */ + gettoken( tmpbuf, size) ; + + /* evaluate it */ + strncpy( tok, getval( tmpbuf), size - 1) ; + tok[ size - 1] = '\0' ; + free( tmpbuf) ; + return TRUE ; +} + /* * get a macro line argument * @@ -303,37 +320,6 @@ int macarg( char *tok, int toksz) return status; } -/* - * nextarg: - * get the next argument - * - * const char *prompt; prompt to use if we must be interactive - * char *buffer; buffer to put token into - * int size; size of the buffer - * int terminator; terminating char to be used on interactive fetch - */ -int nextarg(const char *prompt, char *buffer, int size, int terminator) -{ - char *tmpbuf ; - - /* if we are interactive, go get it! */ - if (clexec == FALSE) - return getstring(prompt, buffer, size, terminator); - - tmpbuf = malloc( size) ; - if( tmpbuf == NULL) - return FALSE ; - - /* grab token and advance past */ - gettoken( tmpbuf, size) ; - - /* evaluate it */ - strncpy( buffer, getval( tmpbuf), size - 1) ; - buffer[ size - 1] = '\0' ; - free( tmpbuf) ; - return TRUE; -} - /* * storemac: * Set up a macro buffer and flag to store all diff --git a/exec.h b/exec.h index a64c786..8a16448 100644 --- a/exec.h +++ b/exec.h @@ -15,13 +15,12 @@ int execproc( int f, int n) ; extern boolean clexec ; /* command line execution flag */ - void ue_system( const char *cmd) ; int namedcmd( int f, int n) ; int execcmd( int f, int n) ; void gettoken( char *tok, int maxtoksize) ; +boolean gettokval( char *tok, int maxtoksize) ; int macarg( char *tok, int toksz) ; -int nextarg( const char *prompt, char *buffer, int size, int terminator) ; int storemac( int f, int n) ; int execbuf( int f, int n) ; int execfile( int f, int n) ; diff --git a/input.c b/input.c index 5e4e960..6d67643 100644 --- a/input.c +++ b/input.c @@ -85,6 +85,23 @@ int mlyesno( const char *prompt) } } +/* + * nextarg: + * get the next argument + * + * const char *prompt; prompt to use if we must be interactive + * char *buffer; buffer to put token into + * int size; size of the buffer + * int terminator; terminating char to be used on interactive fetch + */ +static int nextarg( const char *prompt, char *buf, int size, int terminator) { + /* if we are interactive, go get it! */ + if( clexec == FALSE) + return getstring( prompt, buf, size, terminator) ; + else + return gettokval( buf, size) ; +} + /* * Write a prompt into the message line, then read back a response. Keep * track of the physical position of the cursor. If we are in a keyboard