1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-24 01:56:26 -05:00

Hide details of token extraction inside exec.

This commit is contained in:
Renaud 2015-01-13 16:42:14 +08:00
parent a634ae5087
commit 84919039a5
3 changed files with 10 additions and 8 deletions

4
eval.c
View File

@ -763,7 +763,7 @@ int setvar(int f, int n)
return status; return status;
} else { /* macro line argument */ } else { /* macro line argument */
/* grab token and skip it */ /* grab token and skip it */
execstr = token(execstr, var, NVSIZE + 1); gettoken( var, sizeof var) ;
} }
/* check the legality and find the var */ /* check the legality and find the var */
@ -890,7 +890,7 @@ fvar:
var[4] = 0; var[4] = 0;
if (strcmp(&var[1], "ind") == 0) { if (strcmp(&var[1], "ind") == 0) {
/* grab token, and eval it */ /* grab token, and eval it */
execstr = token(execstr, var, size); gettoken( var, size) ;
strcpy(var, getval(var)); strcpy(var, getval(var));
goto fvar; goto fvar;
} }

11
exec.c
View File

@ -27,7 +27,7 @@
#include "window.h" #include "window.h"
char *execstr = NULL ; /* pointer to string to execute */ static char *execstr = NULL ; /* pointer to string to execute */
boolean clexec = FALSE ; /* command line execution flag */ boolean clexec = FALSE ; /* command line execution flag */
@ -212,8 +212,7 @@ static int docmd( char *cline) {
* char *src, *tok; source string, destination token string * char *src, *tok; source string, destination token string
* int size; maximum size of token * int size; maximum size of token
*/ */
char *token(char *src, char *tok, int size) static char *token( char *src, char *tok, int size) {
{
int quotef; /* is the current string quoted? */ int quotef; /* is the current string quoted? */
char c; /* temporary character */ char c; /* temporary character */
@ -279,6 +278,10 @@ char *token(char *src, char *tok, int size)
return src; return src;
} }
void gettoken( char *tok, int maxtoksize) {
execstr = token( execstr, tok, maxtoksize) ;
}
/* /*
* get a macro line argument * get a macro line argument
* *
@ -312,7 +315,7 @@ int nextarg(const char *prompt, char *buffer, int size, int terminator)
return getstring(prompt, buffer, size, terminator); return getstring(prompt, buffer, size, terminator);
/* grab token and advance past */ /* grab token and advance past */
execstr = token(execstr, buffer, size); gettoken( buffer, size) ;
/* evaluate it */ /* evaluate it */
strncpy( buffer, getval( buffer), size - 1) ; strncpy( buffer, getval( buffer), size - 1) ;

3
exec.h
View File

@ -12,7 +12,6 @@ int execproc( int f, int n) ;
#endif #endif
extern char *execstr ; /* pointer to string to execute */
extern boolean clexec ; /* command line execution flag */ extern boolean clexec ; /* command line execution flag */
@ -20,7 +19,7 @@ extern boolean clexec ; /* command line execution flag */
void ue_system( const char *cmd) ; 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) ; void gettoken( char *tok, int maxtoksize) ;
int macarg( char *tok, int toksz) ; 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) ;