]> Shamusworld >> Repos - rmac/blobdiff - error.c
Fix for bug #174 - when a macro contains an error, actually print the filename it...
[rmac] / error.c
diff --git a/error.c b/error.c
index d0edaf400240ef95a6270aa566af8a9a690d7d27..ce22b395f3d87976f60ca0b8beaabe0a359044d7 100644 (file)
--- a/error.c
+++ b/error.c
@@ -102,7 +102,36 @@ int error(const char * text, ...)
                        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);
+               {
+                       // This is basically SetFilenameForErrorReporting() but we don't call it here
+                       // as it will clobber curfname. That function is used during fixups only so
+                       // it really doesn't matter at that point...
+                       char * filename;
+#include <token.h>
+                       FILEREC * fr;
+                       uint16_t fnum = cur_inobj->inobj.imacro->im_macro->cfileno;
+                       // Check for absolute top filename (this should never happen)
+                       if (fnum == -1)
+                               interror(8);
+                       else
+                       {
+                               fr = filerec;
+
+                               // Advance to the correct record...
+                               while (fr != NULL && fnum != 0)
+                               {
+                                       fr = fr->frec_next;
+                                       fnum--;
+                               }
+                       }
+                       // Check for file # record not found (this should never happen either)
+                       if (fr == NULL)
+                               interror(8);
+
+                       filename = fr->frec_name;
+
+                       sprintf(buf1, "%s %d: Error: %s\n", filename, 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);