X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Ferror.c;h=cba0a479e97ecb2dca7979037abf8696655a93c7;hb=92dfde6c4e748946c5e13323bb48bf2abd72c2b3;hp=d6557c57ca85df624ef6fe31bb2d34e7c12dbebc;hpb=1eff067ff90379c14c6a9770a76d6a3e9f99cd82;p=cc65 diff --git a/src/cc65/error.c b/src/cc65/error.c index d6557c57c..cba0a479e 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -43,6 +43,7 @@ /* cc65 */ #include "global.h" #include "input.h" +#include "lineinfo.h" #include "scanner.h" #include "stmt.h" #include "error.h" @@ -87,7 +88,7 @@ void Warning (const char* Format, ...) { va_list ap; va_start (ap, Format); - IntWarning (GetCurrentFile(), curpos, Format, ap); + IntWarning (GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Format, ap); va_end (ap); } @@ -125,7 +126,7 @@ void Error (const char* Format, ...) { va_list ap; va_start (ap, Format); - IntError (GetCurrentFile(), curpos, Format, ap); + IntError (GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Format, ap); va_end (ap); } @@ -147,7 +148,17 @@ void Fatal (const char* Format, ...) { va_list ap; - fprintf (stderr, "%s(%u): Fatal: ", GetCurrentFile(), curpos); + const char* FileName; + unsigned LineNum; + if (CurTok.LI) { + FileName = GetInputName (CurTok.LI); + LineNum = GetInputLine (CurTok.LI); + } else { + FileName = GetCurrentFile (); + LineNum = GetCurrentLine (); + } + + fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum); va_start (ap, Format); vfprintf (stderr, Format, ap); @@ -160,13 +171,23 @@ void Fatal (const char* Format, ...) -void Internal (char* Format, ...) +void Internal (const char* Format, ...) /* Print a message about an internal compiler error and die. */ { va_list ap; + const char* FileName; + unsigned LineNum; + if (CurTok.LI) { + FileName = GetInputName (CurTok.LI); + LineNum = GetInputLine (CurTok.LI); + } else { + FileName = GetCurrentFile (); + LineNum = GetCurrentLine (); + } + fprintf (stderr, "%s(%u): Internal compiler error:\n", - GetCurrentFile(), curpos); + FileName, LineNum); va_start (ap, Format); vfprintf (stderr, Format, ap); @@ -175,7 +196,7 @@ void Internal (char* Format, ...) /* Use abort to create a core dump */ abort (); -} +} @@ -190,3 +211,4 @@ void ErrorReport (void) +