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:
parent
51967939b8
commit
8d412dc388
6
eval.c
6
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,9 +889,7 @@ 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' ;
|
||||
if( TRUE == gettokval( var, size))
|
||||
goto fvar ;
|
||||
}
|
||||
}
|
||||
|
48
exec.c
48
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
|
||||
|
3
exec.h
3
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) ;
|
||||
|
17
input.c
17
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
|
||||
|
Loading…
Reference in New Issue
Block a user