1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-16 09:36:29 -05:00

Review file scope of functions dealing with token extraction and token evaluation.

This commit is contained in:
Renaud 2015-08-25 16:34:15 +08:00
parent 51967939b8
commit 8d412dc388
4 changed files with 38 additions and 38 deletions

8
eval.c
View File

@ -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 ;
}
}

48
exec.c
View File

@ -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

3
exec.h
View File

@ -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) ;

17
input.c
View File

@ -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