summaryrefslogtreecommitdiff
path: root/preproc.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-07-07 16:00:58 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-07-07 16:00:58 -0700
commit8287daf2a4ea198c6034d37f832036a5f49d695d (patch)
treecdde8b7d6c366392fc4bb83c30fb577251b77143 /preproc.c
parenta23aa4a3e931b0333336406d6b2b30b96c24507d (diff)
downloadnasm-8287daf2a4ea198c6034d37f832036a5f49d695d.tar.gz
nasm-8287daf2a4ea198c6034d37f832036a5f49d695d.tar.bz2
nasm-8287daf2a4ea198c6034d37f832036a5f49d695d.zip
preproc: always reprocess smacros after %+ - pasting
We always need to process %+ at least once, but we also always need to reprocess smacros after pasting. The solution to this is to make sure we always reprocess %+ after the first expansion pass. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'preproc.c')
-rw-r--r--preproc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/preproc.c b/preproc.c
index 8470dff..ab24953 100644
--- a/preproc.c
+++ b/preproc.c
@@ -3638,7 +3638,7 @@ static Token *expand_smacro(Token * tline)
Context *ctx;
const char *mname;
int deadman = DEADMAN_LIMIT;
- bool expanded, pasted;
+ bool expanded;
/*
* Trick: we should avoid changing the start token pointer since it can
@@ -3655,10 +3655,11 @@ static Token *expand_smacro(Token * tline)
org_tline->text = NULL;
}
+ expanded = true; /* Always expand %+ at least once */
+
again:
tail = &thead;
thead = NULL;
- expanded = false;
while (tline) { /* main token loop */
if (!--deadman) {
@@ -3928,13 +3929,13 @@ again:
* Also we look for %+ tokens and concatenate the tokens before and after
* them (without white spaces in between).
*/
- pasted = paste_tokens(&thead, true);
- if (expanded && pasted) {
+ if (expanded && paste_tokens(&thead, true)) {
/*
* If we concatenated something, *and* we had previously expanded
* an actual macro, scan the lines again for macros...
*/
tline = thead;
+ expanded = false;
goto again;
}