1
0
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:
2015-09-27 21:11:51 +08:00
parent b5eb424ad0
commit cfa5c7fb65
4 changed files with 88 additions and 59 deletions

29
exec.c
View File

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