]> Shamusworld >> Repos - rmac/commitdiff
Modified IMACRO and IREPT to store line numbers during definition - error now correct...
authorggn <ggn.dbug@gmail.com>
Wed, 29 Nov 2017 18:47:38 +0000 (20:47 +0200)
committerShamus Hammons <jlhamm@acm.org>
Wed, 29 Nov 2017 19:58:33 +0000 (13:58 -0600)
error.c
macro.c
symbol.h
token.c
token.h

diff --git a/error.c b/error.c
index 75e91490d3d44df485fed4cd180befc545055443..5c9b8c90133b074d9c16750f7342a370d8ec1ed7 100644 (file)
--- a/error.c
+++ b/error.c
@@ -91,7 +91,18 @@ int error(const char * text, ...)
        if (listing > 0)
                ship_ln(buf);
 
        if (listing > 0)
                ship_ln(buf);
 
-       sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
+       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;
+       }
 
        if (err_flag)
                unused = write(err_fd, buf1, (LONG)strlen(buf1));
 
        if (err_flag)
                unused = write(err_fd, buf1, (LONG)strlen(buf1));
diff --git a/macro.c b/macro.c
index 54d34c43687b3cae932b9c7b5387e55b36a9ce99..c92b2dbfa7b65708589ccc02162218017238f675 100644 (file)
--- a/macro.c
+++ b/macro.c
@@ -117,6 +117,7 @@ int defmac1(char * ln, int notEndFlag)
                        curmac->lineList = malloc(sizeof(LLIST));
                        curmac->lineList->next = NULL;
                        curmac->lineList->line = strdup(ln);
                        curmac->lineList = malloc(sizeof(LLIST));
                        curmac->lineList->next = NULL;
                        curmac->lineList->line = strdup(ln);
+                       curmac->lineList->lineno = curlineno;
                        curmac->last = curmac->lineList;
                }
                else
                        curmac->last = curmac->lineList;
                }
                else
@@ -124,6 +125,7 @@ int defmac1(char * ln, int notEndFlag)
                        curmac->last->next = malloc(sizeof(LLIST));
                        curmac->last->next->next = NULL;
                        curmac->last->next->line = strdup(ln);
                        curmac->last->next = malloc(sizeof(LLIST));
                        curmac->last->next->next = NULL;
                        curmac->last->next->line = strdup(ln);
+                       curmac->lineList->lineno = curlineno;
                        curmac->last = curmac->last->next;
                }
 
                        curmac->last = curmac->last->next;
                }
 
@@ -224,6 +226,7 @@ WARNING("!!! Casting (char *) as LONG !!!")
                firstrpt = malloc(sizeof(LLIST));
                firstrpt->next = NULL;
                firstrpt->line = strdup(line);
                firstrpt = malloc(sizeof(LLIST));
                firstrpt->next = NULL;
                firstrpt->line = strdup(line);
+               firstrpt->lineno = curlineno;
                nextrpt = firstrpt;
        }
        else
                nextrpt = firstrpt;
        }
        else
@@ -231,6 +234,7 @@ WARNING("!!! Casting (char *) as LONG !!!")
                nextrpt->next = malloc(sizeof(LLIST));
                nextrpt->next->next = NULL;
                nextrpt->next->line = strdup(line);
                nextrpt->next = malloc(sizeof(LLIST));
                nextrpt->next->next = NULL;
                nextrpt->next->line = strdup(line);
+               nextrpt->next->lineno = curlineno;
                nextrpt = nextrpt->next;
        }
 #endif
                nextrpt = nextrpt->next;
        }
 #endif
index 3dc930f6f94b45629aa9d9764fc9a7c1d5b48dd0..63eda03352fc5a4b5ea88846aa11f0f8dc7ab06d 100644 (file)
--- a/symbol.h
+++ b/symbol.h
@@ -17,6 +17,7 @@ LLIST
 {
        LLIST * next;
        uint8_t * line;
 {
        LLIST * next;
        uint8_t * line;
+       int lineno;
 };
 
 // Symbols
 };
 
 // Symbols
diff --git a/token.c b/token.c
index e1be9b5b8871ea3cde208b29b8e9a072f43ec64d..9754f4e4220750a0b0e92886eb414a60ace3bb8d 100644 (file)
--- a/token.c
+++ b/token.c
@@ -716,6 +716,11 @@ char * GetNextRepeatLine(void)
 
 //             strp = irept->ir_nextln;
        }
 
 //             strp = irept->ir_nextln;
        }
+       // Mark the current macro line in the irept object
+       // This is probably overkill - a global variable
+       // would suffice here (it only gets used during
+       // error reporting anyway)
+       irept->lineno = irept->ir_nextln->lineno;
 
 //     strcpy(irbuf, (char *)(irept->ir_nextln + 1));
        strcpy(irbuf, irept->ir_nextln->line);
 
 //     strcpy(irbuf, (char *)(irept->ir_nextln + 1));
        strcpy(irbuf, irept->ir_nextln->line);
diff --git a/token.h b/token.h
index 28c1f8be562682dd65218efa9ebff4d655541dd3..4a9b1105bb270cd4dd2db2a7efc0ca739f93d92f 100644 (file)
--- a/token.h
+++ b/token.h
@@ -146,6 +146,7 @@ IREPT {
        LLIST * ir_firstln;             // Pointer to first line
        LLIST * ir_nextln;              // Pointer to next line
        uint32_t ir_count;              // Repeat count (decrements)
        LLIST * ir_firstln;             // Pointer to first line
        LLIST * ir_nextln;              // Pointer to next line
        uint32_t ir_count;              // Repeat count (decrements)
+       uint32_t lineno;                // Repeat line number (Convert this to global instead of putting it here?)
 };
 
 // Exported variables
 };
 
 // Exported variables