mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
asm/preproc.c: generalize pp_pre_command()
Generalize pp_pre_command() so that the first argument doesn't have to be a preprocessor token. Instead, the two arguments are now both turned into token streams, separated by a whitespace token. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
@@ -1100,6 +1100,19 @@ static Token *cut_tlist(Token *t)
|
||||
return nt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the pointer to the end of a tlist. If the tlist is empty,
|
||||
* return the incoming pointer.
|
||||
*/
|
||||
static Token **tlist_endptr(Token **tptr)
|
||||
{
|
||||
Token *t;
|
||||
while ((t = *tptr))
|
||||
tptr = &t->next;
|
||||
|
||||
return tptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new MMacro. This does not claim a refcount; the appropriate
|
||||
* get_mmacro() calls need to be added.
|
||||
@@ -8920,13 +8933,17 @@ void pp_pre_undefine(char *definition)
|
||||
/* Insert an early preprocessor command that doesn't need special handling */
|
||||
void pp_pre_command(const char *what, char *string)
|
||||
{
|
||||
Token *def, *space;
|
||||
Token *def;
|
||||
Line *l;
|
||||
|
||||
def = tokenize(string);
|
||||
|
||||
if (what) {
|
||||
space = new_White(def);
|
||||
def = new_Token(space, TOKEN_PREPROC_ID, what, 0);
|
||||
Token *wt = tokenize(what);
|
||||
Token **tailp = tlist_endptr(&wt);
|
||||
|
||||
*tailp = new_White(def);
|
||||
def = wt;
|
||||
}
|
||||
|
||||
nasm_new(l);
|
||||
|
Reference in New Issue
Block a user