1
0
mirror of https://github.com/cc65/cc65.git synced 2024-10-01 15:54:59 +00:00

Use Line only if available

git-svn-id: svn://svn.cc65.org/cc65/trunk@3238 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2004-10-10 10:30:03 +00:00
parent 340a16e399
commit 19e1167b82

View File

@ -75,9 +75,11 @@ static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg,
fprintf (stderr, "%s(%u): Warning: ", Filename, LineNo); fprintf (stderr, "%s(%u): Warning: ", Filename, LineNo);
vfprintf (stderr, Msg, ap); vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); if (Line) {
++WarningCount; Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line));
}
++WarningCount;
} }
} }
@ -112,7 +114,9 @@ static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va
vfprintf (stderr, Msg, ap); vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); if (Line) {
Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line));
}
++ErrorCount; ++ErrorCount;
if (ErrorCount > 10) { if (ErrorCount > 10) {
Fatal ("Too many errors"); Fatal ("Too many errors");
@ -151,11 +155,11 @@ void Fatal (const char* Format, ...)
const char* FileName; const char* FileName;
unsigned LineNum; unsigned LineNum;
if (CurTok.LI) { if (CurTok.LI) {
FileName = GetInputName (CurTok.LI); FileName = GetInputName (CurTok.LI);
LineNum = GetInputLine (CurTok.LI); LineNum = GetInputLine (CurTok.LI);
} else { } else {
FileName = GetCurrentFile (); FileName = GetCurrentFile ();
LineNum = GetCurrentLine (); LineNum = GetCurrentLine ();
} }
fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum); fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum);
@ -165,7 +169,9 @@ void Fatal (const char* Format, ...)
va_end (ap); va_end (ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); if (Line) {
Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line));
}
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
@ -179,20 +185,23 @@ void Internal (const char* Format, ...)
const char* FileName; const char* FileName;
unsigned LineNum; unsigned LineNum;
if (CurTok.LI) { if (CurTok.LI) {
FileName = GetInputName (CurTok.LI); FileName = GetInputName (CurTok.LI);
LineNum = GetInputLine (CurTok.LI); LineNum = GetInputLine (CurTok.LI);
} else { } else {
FileName = GetCurrentFile (); FileName = GetCurrentFile ();
LineNum = GetCurrentLine (); LineNum = GetCurrentLine ();
} }
fprintf (stderr, "%s(%u): Internal compiler error:\n", fprintf (stderr, "%s(%u): Internal compiler error:\n",
FileName, LineNum); FileName, LineNum);
va_start (ap, Format); va_start (ap, Format);
vfprintf (stderr, Format, ap); vfprintf (stderr, Format, ap);
va_end (ap); va_end (ap);
fprintf (stderr, "\nInput: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line));
if (Line) {
fprintf (stderr, "\nInput: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line));
}
/* Use abort to create a core dump */ /* Use abort to create a core dump */
abort (); abort ();