Skip to content

Commit 2c63ab0

Browse files
author
H. Peter Anvin
committed
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>
1 parent f1b6d31 commit 2c63ab0

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

asm/preproc.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,19 @@ static Token *cut_tlist(Token *t)
11001100
return nt;
11011101
}
11021102

1103+
/*
1104+
* Find the pointer to the end of a tlist. If the tlist is empty,
1105+
* return the incoming pointer.
1106+
*/
1107+
static Token **tlist_endptr(Token **tptr)
1108+
{
1109+
Token *t;
1110+
while ((t = *tptr))
1111+
tptr = &t->next;
1112+
1113+
return tptr;
1114+
}
1115+
11031116
/*
11041117
* Allocate a new MMacro. This does not claim a refcount; the appropriate
11051118
* get_mmacro() calls need to be added.
@@ -8920,13 +8933,17 @@ void pp_pre_undefine(char *definition)
89208933
/* Insert an early preprocessor command that doesn't need special handling */
89218934
void pp_pre_command(const char *what, char *string)
89228935
{
8923-
Token *def, *space;
8936+
Token *def;
89248937
Line *l;
89258938

89268939
def = tokenize(string);
8940+
89278941
if (what) {
8928-
space = new_White(def);
8929-
def = new_Token(space, TOKEN_PREPROC_ID, what, 0);
8942+
Token *wt = tokenize(what);
8943+
Token **tailp = tlist_endptr(&wt);
8944+
8945+
*tailp = new_White(def);
8946+
def = wt;
89308947
}
89318948

89328949
nasm_new(l);

0 commit comments

Comments
 (0)