From: ggn Date: Wed, 29 Nov 2017 18:47:38 +0000 (+0200) Subject: Modified IMACRO and IREPT to store line numbers during definition - error now correct... X-Git-Tag: v2.1.0~98 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=commitdiff_plain;h=c2caacfdc844e2f8b5d05b0699fbacc04b4ce8ea Modified IMACRO and IREPT to store line numbers during definition - error now correctly prints source line number --- diff --git a/error.c b/error.c index 75e9149..5c9b8c9 100644 --- a/error.c +++ b/error.c @@ -91,7 +91,18 @@ int error(const char * text, ...) 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)); diff --git a/macro.c b/macro.c index 54d34c4..c92b2db 100644 --- 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->lineno = curlineno; 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->lineList->lineno = curlineno; 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->lineno = curlineno; 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->lineno = curlineno; nextrpt = nextrpt->next; } #endif diff --git a/symbol.h b/symbol.h index 3dc930f..63eda03 100644 --- a/symbol.h +++ b/symbol.h @@ -17,6 +17,7 @@ LLIST { LLIST * next; uint8_t * line; + int lineno; }; // Symbols diff --git a/token.c b/token.c index e1be9b5..9754f4e 100644 --- a/token.c +++ b/token.c @@ -716,6 +716,11 @@ char * GetNextRepeatLine(void) // 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); diff --git a/token.h b/token.h index 28c1f8b..4a9b110 100644 --- 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) + uint32_t lineno; // Repeat line number (Convert this to global instead of putting it here?) }; // Exported variables