BR3074517: Print %macro name inside %rep blocks
authorCyrill Gorcunov <gorcunov@gmail.com>
Fri, 24 Sep 2010 11:24:42 +0000 (15:24 +0400)
committerCyrill Gorcunov <gorcunov@gmail.com>
Fri, 24 Sep 2010 11:24:42 +0000 (15:24 +0400)
If we're to print inside %rep block we should find
out which %macro it belongs.

Reported-by: Rob Neff
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
preproc.c

index f9a2f859b4d75cfc3e099c0c2b4dadf74b9bbdbf..f21445b3d3afa97e1e4bc20288222c1b538015b4 100644 (file)
--- a/preproc.c
+++ b/preproc.c
@@ -4745,12 +4745,22 @@ static int expand_mmacro(Token * tline)
 static void verror(int severity, const char *fmt, va_list arg)
 {
     char buff[1024];
+    MMacro *mmac = NULL;
+    int delta = 0;
 
     vsnprintf(buff, sizeof(buff), fmt, arg);
 
-    if (istk && istk->mstk && istk->mstk->name)
-        nasm_error(severity, "(%s:%d) %s", istk->mstk->name,
-               istk->mstk->lineno, buff);
+    /* get %macro name */
+    if (istk && istk->mstk) {
+        mmac = istk->mstk;
+        /* but %rep blocks should be skipped */
+        while (mmac && !mmac->name)
+            mmac = mmac->next_active, delta++;
+    }
+
+    if (mmac)
+        nasm_error(severity, "(%s:%d) %s",
+                   mmac->name, mmac->lineno - delta, buff);
     else
         nasm_error(severity, "%s", buff);
 }