When an error occurs inside a macro or rept, report the exact line, not the line...
authorggn <ggn.dbug@gmail.com>
Tue, 23 Jan 2018 12:46:00 +0000 (14:46 +0200)
committerShamus Hammons <jlhamm@acm.org>
Wed, 24 Jan 2018 02:40:22 +0000 (20:40 -0600)
error.c

diff --git a/error.c b/error.c
index 5c9b8c90133b074d9c16750f7342a370d8ec1ed7..13b3199a856bd4631044487975ae6ccccd5555df 100644 (file)
--- a/error.c
+++ b/error.c
@@ -91,18 +91,24 @@ int error(const char * text, ...)
        if (listing > 0)
                ship_ln(buf);
 
-       switch (cur_inobj->in_type)
+       if (cur_inobj)
        {
-       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;
+               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));