mirror of https://github.com/rfivet/uemacs.git
Use temporary buffer in nextarg to avoid issue with strncpy under Linux.
This commit is contained in:
parent
fe1eaf7348
commit
bc90c36603
8
exec.c
8
exec.c
|
@ -310,16 +310,20 @@ 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)
|
||||||
{
|
{
|
||||||
|
char *tmpbuf ;
|
||||||
|
|
||||||
/* if we are interactive, go get it! */
|
/* if we are interactive, go get it! */
|
||||||
if (clexec == FALSE)
|
if (clexec == FALSE)
|
||||||
return getstring(prompt, buffer, size, terminator);
|
return getstring(prompt, buffer, size, terminator);
|
||||||
|
|
||||||
|
tmpbuf = malloc( size) ;
|
||||||
/* grab token and advance past */
|
/* grab token and advance past */
|
||||||
gettoken( buffer, size) ;
|
gettoken( tmpbuf, size) ;
|
||||||
|
|
||||||
/* evaluate it */
|
/* evaluate it */
|
||||||
strncpy( buffer, getval( buffer), size - 1) ;
|
strncpy( buffer, getval( tmpbuf), size - 1) ;
|
||||||
buffer[ size - 1] = '\0' ;
|
buffer[ size - 1] = '\0' ;
|
||||||
|
free( tmpbuf) ;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue