mirror of
https://github.com/rfivet/uemacs.git
synced 2025-09-26 15:04:04 -04:00
Review getnewtoken, introduce getnewtokval and rewrite function evaluation accordingly.
This commit is contained in:
29
exec.c
29
exec.c
@@ -327,15 +327,18 @@ void gettoken( char *tok, int maxtoksize) {
|
||||
execstr = token( execstr, tok, maxtoksize) ;
|
||||
}
|
||||
|
||||
void getnewtoken( char **tokref) {
|
||||
execstr = newtoken( execstr, tokref) ;
|
||||
static char *getnewtoken( void) {
|
||||
char *tok ;
|
||||
|
||||
execstr = newtoken( execstr, &tok) ;
|
||||
return tok ;
|
||||
}
|
||||
|
||||
boolean gettokval( char *tok, int size) {
|
||||
char *tmpbuf ;
|
||||
|
||||
/* grab token and advance past */
|
||||
getnewtoken( &tmpbuf) ;
|
||||
tmpbuf = getnewtoken() ;
|
||||
if( tmpbuf == NULL)
|
||||
return FALSE ;
|
||||
|
||||
@@ -346,6 +349,26 @@ boolean gettokval( char *tok, int size) {
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
char *getnewtokval( void) {
|
||||
char *tmpbuf ;
|
||||
char *tmpval ;
|
||||
char *valbuf ;
|
||||
|
||||
/* grab token and advance past */
|
||||
tmpbuf = getnewtoken() ;
|
||||
if( tmpbuf == NULL)
|
||||
return NULL ;
|
||||
|
||||
/* evaluate it */
|
||||
tmpval = getval( tmpbuf) ;
|
||||
valbuf = malloc( strlen( tmpval) + 1 ) ;
|
||||
if( valbuf != NULL)
|
||||
strcpy( valbuf, tmpval) ;
|
||||
|
||||
free( tmpbuf) ;
|
||||
return valbuf ;
|
||||
}
|
||||
|
||||
/*
|
||||
* get a macro line argument
|
||||
*
|
||||
|
Reference in New Issue
Block a user