summaryrefslogtreecommitdiff
path: root/preproc.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2002-04-30 20:53:16 +0000
committerH. Peter Anvin <hpa@zytor.com>2002-04-30 20:53:16 +0000
commit87bc61964cf5d2cc2e322883d6f927a43fb53af3 (patch)
treecf5f2e9602092902807762c09912a5e520121368 /preproc.c
parent76690a12ad212d1f77cd1f71d7ac5a9de6eaefb6 (diff)
downloadnasm-87bc61964cf5d2cc2e322883d6f927a43fb53af3.tar.gz
nasm-87bc61964cf5d2cc2e322883d6f927a43fb53af3.tar.bz2
nasm-87bc61964cf5d2cc2e322883d6f927a43fb53af3.zip
NASM 0.97
Diffstat (limited to 'preproc.c')
-rw-r--r--preproc.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/preproc.c b/preproc.c
index 4318e33..032854e 100644
--- a/preproc.c
+++ b/preproc.c
@@ -2604,9 +2604,17 @@ static int expand_mmacro (Token *tline) {
/*
* If we had a label, push it on the front of the first line of
- * the macro expansion.
+ * the macro expansion. We must check that this doesn't give
+ * two consecutive TOK_WHITESPACE.
*/
if (label) {
+ if (last->type == TOK_WHITESPACE &&
+ istk->expansion->first->type == TOK_WHITESPACE) {
+ Token *victim = istk->expansion->first; /* kill this whitespace */
+ istk->expansion->first = victim->next;
+ nasm_free (victim->text);
+ nasm_free (victim);
+ }
last->next = istk->expansion->first;
istk->expansion->first = label;
}
@@ -2706,6 +2714,25 @@ static char *pp_getline (void) {
}
line_sync();
} else {
+ /*
+ * Check whether a `%rep' was started and not ended
+ * within this macro expansion. This can happen and
+ * should be detected. It's a fatal error because
+ * I'm too confused to work out how to recover
+ * sensibly from it.
+ */
+ if (defining) {
+ if (defining->name)
+ error (ERR_PANIC,
+ "defining with name in expansion");
+ else if (!istk->mstk->name)
+ error (ERR_PANIC, "istk->mstk has no name but"
+ " defining is set at end of expansion");
+ else
+ error (ERR_FATAL, "`%%rep' without `%%endrep' within"
+ " expansion of macro `%s'", istk->mstk->name);
+ }
+
if (istk->mstk->name) {
/*
* This was a real macro call, not a %rep, and