Bugzilla – Attachment 148 Details for
Bug 174
Macros defined in one file and called from another with errors in their definitions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Ugh!
0001-Fix-for-bug-174-when-a-macro-contains-an-error-actua.patch (text/plain), 3.74 KB, created by
ggn
on 2020-09-02 14:50:23 CDT
(
hide
)
Description:
Ugh!
Filename:
MIME Type:
Creator:
ggn
Created:
2020-09-02 14:50:23 CDT
Size:
3.74 KB
patch
obsolete
>From 44c84ecbc63663baea68ebe7230ed89fa6ada3e0 Mon Sep 17 00:00:00 2001 >From: ggn <ggn.dbug@gmail.com> >Date: Wed, 2 Sep 2020 22:49:42 +0300 >Subject: [PATCH] Fix for bug #174 - when a macro contains an error, actually > print the filename it was defined in, instead of current filename > >--- > error.c | 31 ++++++++++++++++++++++++++++++- > symbol.c | 3 +++ > symbol.h | 1 + > token.c | 7 ------- > token.h | 9 +++++++++ > 5 files changed, 43 insertions(+), 8 deletions(-) > >diff --git a/error.c b/error.c >index 664aecb..b98aa5f 100644 >--- 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); >diff --git a/symbol.c b/symbol.c >index f8a43d6..7008dce 100644 >--- a/symbol.c >+++ b/symbol.c >@@ -103,6 +103,9 @@ SYM * NewSymbol(uint8_t * name, int type, int envno) > symbol->sorder = NULL; > symbol->uid = currentUID++; > >+ // Record filename the symbol is defined (for now only used by macro error reporting) >+ symbol->cfileno = cfileno; >+ > // Install symbol in the symbol table > int hash = HashSymbol(name, envno); > symbol->snext = symbolTable[hash]; >diff --git a/symbol.h b/symbol.h >index fadb8a4..2496dbf 100644 >--- a/symbol.h >+++ b/symbol.h >@@ -35,6 +35,7 @@ SYM > uint8_t * sname; // * -> Symbol's print-name > LLIST * lineList; // * -> Macro's linked list of lines > LLIST * last; // * -> end of macro linked list >+ uint16_t cfileno; // File the macro is defined in > uint32_t uid; // Symbol's unique ID > }; > >diff --git a/token.c b/token.c >index 9299e3f..c9baf81 100644 >--- a/token.c >+++ b/token.c >@@ -40,13 +40,6 @@ TOKEN tokeol[1] = {EOL}; // Bailout end-of-line token > char * string[TOKBUFSIZE*2];// Token buffer string pointer storage > int optimizeOff; // Optimization override flag > >-// File record, used to maintain a list of every include file ever visited >-#define FILEREC struct _filerec >-FILEREC >-{ >- FILEREC * frec_next; >- char * frec_name; >-}; > > FILEREC * filerec; > FILEREC * last_fr; >diff --git a/token.h b/token.h >index 95adf01..fa1f4ec 100644 >--- a/token.h >+++ b/token.h >@@ -152,6 +152,14 @@ IREPT { > uint32_t lineno; // Repeat line number (Convert this to global instead of putting it here?) > }; > >+// File record, used to maintain a list of every include file ever visited >+#define FILEREC struct _filerec >+FILEREC >+{ >+ FILEREC * frec_next; >+ char* frec_name; >+}; >+ > // Exported variables > extern int lnsave; > extern uint32_t curlineno; >@@ -165,6 +173,7 @@ extern INOBJ * cur_inobj; > extern int mjump_align; > extern char * string[]; > extern int optimizeOff; >+extern FILEREC* filerec; > > // Exported functions > int include(int, char *); >-- >2.25.0.windows.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 174
: 148