1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 15:26:23 -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 */
if (clexec) {
macarg(tok); /* get the next token */
macarg( tok, sizeof tok) ; /* get the next token */
return stock(tok);
}

7
eval.c
View File

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

14
exec.c
View File

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

2
exec.h
View File

@ -21,7 +21,7 @@ void ue_system( const char *cmd) ;
int namedcmd( int f, int n) ;
int execcmd( int f, int n) ;
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 storemac( 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 (clexec) {
if (macarg(buf) != TRUE)
if( macarg( buf, sizeof buf) != TRUE)
return NULL;
return fncmatch(&buf[0]);
}