diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-09 10:18:45 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-09 10:18:45 -0700 |
commit | c751e86145aec99b2212321903146723e75af22a (patch) | |
tree | a122578dcd9f3461c43dd9f9b81b64d832208866 | |
parent | 435f1863be5627fd4541e283bb12727b7a91445c (diff) | |
download | nasm-c751e86145aec99b2212321903146723e75af22a.tar.gz |
Fix %? in multi-line macros with a labelnasm-2.03
The handling of %? in multi-line macros was broken when the macro name
was preceeded by a label; it would expand to the label instead of the
macro name. This was particularly serious since this was used in
the macro implementation of INCBIN.
-rw-r--r-- | preproc.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -393,7 +393,8 @@ static void make_tok_num(Token * tok, int64_t val); static void error(int severity, const char *fmt, ...); static void *new_Block(size_t size); static void delete_Blocks(void); -static Token *new_Token(Token * next, enum pp_token_type type, char *text, int txtlen); +static Token *new_Token(Token * next, enum pp_token_type type, + const char *text, int txtlen); static Token *delete_Token(Token * t); /* @@ -986,7 +987,7 @@ static void delete_Blocks(void) * also the mac and next elements to NULL. */ static Token *new_Token(Token * next, enum pp_token_type type, - char *text, int txtlen) + const char *text, int txtlen) { Token *t; int i; @@ -3752,6 +3753,7 @@ static int expand_mmacro(Token * tline) MMacro *m; Line *l, *ll; int i, nparam, *paramlen; + const char *mname; t = tline; skip_white_(t); @@ -3760,7 +3762,9 @@ static int expand_mmacro(Token * tline) return 0; mtok = t; m = is_mmacro(t, ¶ms); - if (!m) { + if (m) { + mname = t->text; + } else { Token *last; /* * We have an id which isn't a macro call. We'll assume @@ -3781,6 +3785,7 @@ static int expand_mmacro(Token * tline) if (!tok_type_(t, TOK_ID) || (m = is_mmacro(t, ¶ms)) == NULL) return 0; last->next = NULL; + mname = t->text; tline = t; } @@ -3859,7 +3864,7 @@ static int expand_mmacro(Token * tline) Token *x = t; switch (t->type) { case TOK_PREPROC_Q: - tt = *tail = new_Token(NULL, TOK_ID, mtok->text, 0); + tt = *tail = new_Token(NULL, TOK_ID, mname, 0); break; case TOK_PREPROC_QQ: tt = *tail = new_Token(NULL, TOK_ID, m->name, 0); |