]> Shamusworld >> Repos - rmac/blobdiff - error.c
When an error occurs inside a macro or rept, report the exact line, not the line...
[rmac] / error.c
diff --git a/error.c b/error.c
index 6da93e2079a279a2c03f5b3a0e6a945c139cbea6..13b3199a856bd4631044487975ae6ccccd5555df 100644 (file)
--- a/error.c
+++ b/error.c
@@ -19,11 +19,19 @@ static long unused;                         // For supressing 'write' warnings
 
 //
 // Report error if not at EOL
+// N.B.: Since this should *never* happen, we can feel free to add whatever
+//       diagnostics that will help in tracking down a problem to this function.
 //
 int at_eol(void)
 {
        if (*tok != EOL)
+       {
                error("syntax error. expected EOL, found $%X ('%c')", *tok, *tok);
+               printf("Token = ");
+               DumpToken(*tok);
+               printf("\n");
+               DumpTokenBuffer();
+       }
 
        return 0;
 }
@@ -83,7 +91,24 @@ int error(const char * text, ...)
        if (listing > 0)
                ship_ln(buf);
 
-       sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
+       if (cur_inobj)
+       {
+               switch (cur_inobj->in_type)
+               {
+               case SRC_IFILE:
+                       sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
+                       break;
+               case SRC_IMACRO:
+                       sprintf(buf1, "%s %d: Error: %s\n", curfname, cur_inobj->inobj.imacro->im_macro->lineList->lineno, buf);
+                       break;
+               case SRC_IREPT:
+                       sprintf(buf1, "%s %d: Error: %s\n", curfname, cur_inobj->inobj.irept->lineno, buf);
+                       break;
+               }
+       }
+       else
+               // No current file so cur_inobj is NULL
+               sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
 
        if (err_flag)
                unused = write(err_fd, buf1, (LONG)strlen(buf1));