1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-20 16:22:38 -05:00

macarg takes buffer length as parameter instead of assuming all buffer have NSTRING size.

This commit is contained in:
Renaud 2015-01-08 12:46:46 +08:00
parent d2d3581e74
commit b596a3a09c
5 changed files with 14 additions and 13 deletions

2
bind.c
View File

@ -444,7 +444,7 @@ unsigned int getckey(int mflag)
/* check to see if we are executing a command line */ /* check to see if we are executing a command line */
if (clexec) { if (clexec) {
macarg(tok); /* get the next token */ macarg( tok, sizeof tok) ; /* get the next token */
return stock(tok); return stock(tok);
} }

7
eval.c
View File

@ -309,7 +309,6 @@ void varinit(void)
char *gtfun(char *fname) char *gtfun(char *fname)
{ {
int fnum; /* index to function to eval */ int fnum; /* index to function to eval */
int status; /* return status */
char *tsp; /* temporary string pointer */ char *tsp; /* temporary string pointer */
char arg1[NSTRING]; /* value of first argument */ char arg1[NSTRING]; /* value of first argument */
char arg2[NSTRING]; /* value of second argument */ char arg2[NSTRING]; /* value of second argument */
@ -335,17 +334,17 @@ char *gtfun(char *fname)
/* if needed, retrieve the first argument */ /* if needed, retrieve the first argument */
if (funcs[fnum].f_type >= MONAMIC) { if (funcs[fnum].f_type >= MONAMIC) {
if ((status = macarg(arg1)) != TRUE) if( macarg( arg1, sizeof arg1) != TRUE)
return errorm; return errorm;
/* if needed, retrieve the second argument */ /* if needed, retrieve the second argument */
if (funcs[fnum].f_type >= DYNAMIC) { if (funcs[fnum].f_type >= DYNAMIC) {
if ((status = macarg(arg2)) != TRUE) if( macarg( arg2, sizeof arg2) != TRUE)
return errorm; return errorm;
/* if needed, retrieve the third argument */ /* if needed, retrieve the third argument */
if (funcs[fnum].f_type >= TRINAMIC) if (funcs[fnum].f_type >= TRINAMIC)
if ((status = macarg(arg3)) != TRUE) if( macarg( arg3, sizeof arg3) != TRUE)
return errorm; return errorm;
} }
} }

14
exec.c
View File

@ -167,7 +167,8 @@ static int docmd( char *cline) {
lastflag = thisflag; lastflag = thisflag;
thisflag = 0; thisflag = 0;
if ((status = macarg(tkn)) != TRUE) { /* and grab the first token */ status = macarg( tkn, sizeof tkn) ;
if( status != TRUE) { /* and grab the first token */
execstr = oldestr; execstr = oldestr;
return status; return status;
} }
@ -179,7 +180,8 @@ static int docmd( char *cline) {
n = atoi(tkn); n = atoi(tkn);
/* and now get the command to execute */ /* and now get the command to execute */
if ((status = macarg(tkn)) != TRUE) { status = macarg( tkn, sizeof tkn) ;
if( status != TRUE) {
execstr = oldestr; execstr = oldestr;
return status; return status;
} }
@ -282,14 +284,14 @@ char *token(char *src, char *tok, int size)
* *
* char *tok; buffer to place argument * char *tok; buffer to place argument
*/ */
int macarg(char *tok) int macarg( char *tok, int toksz)
{ {
boolean savcle ; /* buffer to store original clexec */ boolean savcle ; /* buffer to store original clexec */
int status; int status;
savcle = clexec; /* save execution mode */ savcle = clexec; /* save execution mode */
clexec = TRUE; /* get the argument */ clexec = TRUE; /* get the argument */
status = nextarg("", tok, NSTRING, ctoec('\n')); status = nextarg("", tok, toksz, ctoec('\n'));
clexec = savcle; /* restore execution mode */ clexec = savcle; /* restore execution mode */
return status; return status;
} }
@ -748,7 +750,7 @@ static int dobuf(struct buffer *bp)
case DIF: /* IF directive */ case DIF: /* IF directive */
/* grab the value of the logical exp */ /* grab the value of the logical exp */
if (execlevel == 0) { if (execlevel == 0) {
if (macarg(tkn) != TRUE) if( macarg( tkn, sizeof tkn) != TRUE)
goto eexec; goto eexec;
if (stol(tkn) == FALSE) if (stol(tkn) == FALSE)
++execlevel; ++execlevel;
@ -759,7 +761,7 @@ static int dobuf(struct buffer *bp)
case DWHILE: /* WHILE directive */ case DWHILE: /* WHILE directive */
/* grab the value of the logical exp */ /* grab the value of the logical exp */
if (execlevel == 0) { if (execlevel == 0) {
if (macarg(tkn) != TRUE) if( macarg( tkn, sizeof tkn) != TRUE)
goto eexec; goto eexec;
if (stol(tkn) == TRUE) if (stol(tkn) == TRUE)
goto onward; goto onward;

2
exec.h
View File

@ -21,7 +21,7 @@ void ue_system( const char *cmd) ;
int namedcmd( int f, int n) ; int namedcmd( int f, int n) ;
int execcmd( int f, int n) ; int execcmd( int f, int n) ;
char *token( char *src, char *tok, int size) ; char *token( char *src, char *tok, int size) ;
int macarg( char *tok) ; int macarg( char *tok, int toksz) ;
int nextarg( const char *prompt, char *buffer, int size, int terminator) ; int nextarg( const char *prompt, char *buffer, int size, int terminator) ;
int storemac( int f, int n) ; int storemac( int f, int n) ;
int execbuf( int f, int n) ; int execbuf( int f, int n) ;

View File

@ -147,7 +147,7 @@ fn_t getname(void)
/* if we are executing a command line get the next arg and match it */ /* if we are executing a command line get the next arg and match it */
if (clexec) { if (clexec) {
if (macarg(buf) != TRUE) if( macarg( buf, sizeof buf) != TRUE)
return NULL; return NULL;
return fncmatch(&buf[0]); return fncmatch(&buf[0]);
} }