mirror of
https://github.com/cc65/cc65.git
synced 2024-06-09 22:29:35 +00:00
Standard formatting of error messages.
https://www.gnu.org/prep/standards/html_node/Errors.html Issue: https://github.com/cc65/cc65/issues/1494
This commit is contained in:
parent
bda5bf70ce
commit
bcc670ee36
|
@ -84,7 +84,7 @@ static void VPrintMsg (const FilePos* Pos, const char* Desc,
|
||||||
SB_Terminate (&Msg);
|
SB_Terminate (&Msg);
|
||||||
|
|
||||||
/* Format the message header */
|
/* Format the message header */
|
||||||
SB_Printf (&S, "%s(%u): %s: ",
|
SB_Printf (&S, "%s:%u: %s: ",
|
||||||
SB_GetConstBuf (GetFileName (Pos->Name)),
|
SB_GetConstBuf (GetFileName (Pos->Name)),
|
||||||
Pos->Line,
|
Pos->Line,
|
||||||
Desc);
|
Desc);
|
||||||
|
|
|
@ -129,7 +129,7 @@ void Fatal (const char* Format, ...)
|
||||||
LineNum = GetCurrentLine ();
|
LineNum = GetCurrentLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum);
|
fprintf (stderr, "%s:%u: Fatal: ", FileName, LineNum);
|
||||||
|
|
||||||
va_start (ap, Format);
|
va_start (ap, Format);
|
||||||
vfprintf (stderr, Format, ap);
|
vfprintf (stderr, Format, ap);
|
||||||
|
@ -159,7 +159,7 @@ void Internal (const char* Format, ...)
|
||||||
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);
|
||||||
|
@ -186,7 +186,7 @@ void Internal (const char* Format, ...)
|
||||||
static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va_list ap)
|
static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va_list ap)
|
||||||
/* Print an error message - internal function*/
|
/* Print an error message - internal function*/
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s(%u): Error: ", Filename, LineNo);
|
fprintf (stderr, "%s:%u: Error: ", Filename, LineNo);
|
||||||
vfprintf (stderr, Msg, ap);
|
vfprintf (stderr, Msg, ap);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg,
|
||||||
|
|
||||||
} else if (IS_Get (&WarnEnable)) {
|
} else if (IS_Get (&WarnEnable)) {
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
|
|
|
@ -784,7 +784,7 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
|
||||||
|
|
||||||
static void MakeMessage (const char* Message)
|
static void MakeMessage (const char* Message)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message);
|
fprintf (stderr, "%s:%u: Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1396,7 +1396,7 @@ void Preprocess (void)
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
if (Verbosity > 1 && SB_NotEmpty (Line)) {
|
if (Verbosity > 1 && SB_NotEmpty (Line)) {
|
||||||
printf ("%s(%u): %.*s\n", GetCurrentFile (), GetCurrentLine (),
|
printf ("%s:%u: %.*s\n", GetCurrentFile (), GetCurrentLine (),
|
||||||
(int) SB_GetLen (Line), SB_GetConstBuf (Line));
|
(int) SB_GetLen (Line), SB_GetConstBuf (Line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
|
||||||
SB_Terminate (&Ident);
|
SB_Terminate (&Ident);
|
||||||
} else {
|
} else {
|
||||||
if (!IgnoreUnknown) {
|
if (!IgnoreUnknown) {
|
||||||
Error ("%s(%u): Syntax error", Filename, Line);
|
Error ("%s:%u: Syntax error", Filename, Line);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
|
||||||
++L;
|
++L;
|
||||||
} else {
|
} else {
|
||||||
if (!IgnoreUnknown) {
|
if (!IgnoreUnknown) {
|
||||||
Error ("%s(%u): Missing '='", Filename, Line);
|
Error ("%s:%u: Missing '='", Filename, Line);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
|
||||||
/* Must have at least one digit */
|
/* Must have at least one digit */
|
||||||
if (Digits == 0) {
|
if (Digits == 0) {
|
||||||
if (!IgnoreUnknown) {
|
if (!IgnoreUnknown) {
|
||||||
Error ("%s(%u): Error in number format", Filename, Line);
|
Error ("%s:%u: Error in number format", Filename, Line);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
|
||||||
/* Check for a comment character or end of line */
|
/* Check for a comment character or end of line */
|
||||||
if (*L != CommentStart && *L != '\0') {
|
if (*L != CommentStart && *L != '\0') {
|
||||||
if (!IgnoreUnknown) {
|
if (!IgnoreUnknown) {
|
||||||
Error ("%s(%u): Trailing garbage", Filename, Line);
|
Error ("%s:%u: Trailing garbage", Filename, Line);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ void InfoWarning (const char* Format, ...)
|
||||||
xvsprintf (Buf, sizeof (Buf), Format, ap);
|
xvsprintf (Buf, sizeof (Buf), Format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
fprintf (stderr, "%s(%u): Warning: %s\n",
|
fprintf (stderr, "%s:%u: Warning: %s\n",
|
||||||
InputSrcName, InfoErrorLine, Buf);
|
InputSrcName, InfoErrorLine, Buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void InfoError (const char* Format, ...)
|
||||||
xvsprintf (Buf, sizeof (Buf), Format, ap);
|
xvsprintf (Buf, sizeof (Buf), Format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
fprintf (stderr, "%s(%u): Error: %s\n",
|
fprintf (stderr, "%s:%u: Error: %s\n",
|
||||||
InputSrcName, InfoErrorLine, Buf);
|
InputSrcName, InfoErrorLine, Buf);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,12 +140,12 @@ void CheckAssertions (void)
|
||||||
|
|
||||||
case ASSERT_ACT_WARN:
|
case ASSERT_ACT_WARN:
|
||||||
case ASSERT_ACT_LDWARN:
|
case ASSERT_ACT_LDWARN:
|
||||||
Warning ("%s(%u): %s", Module, Line, Message);
|
Warning ("%s:%u: %s", Module, Line, Message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASSERT_ACT_ERROR:
|
case ASSERT_ACT_ERROR:
|
||||||
case ASSERT_ACT_LDERROR:
|
case ASSERT_ACT_LDERROR:
|
||||||
Error ("%s(%u): %s", Module, Line, Message);
|
Error ("%s:%u: %s", Module, Line, Message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -774,17 +774,19 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data)
|
||||||
if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) {
|
if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) {
|
||||||
/* Unresolved external */
|
/* Unresolved external */
|
||||||
Import* Imp = E->ImpList;
|
Import* Imp = E->ImpList;
|
||||||
|
const char * name = GetString (E->Name);
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Unresolved external '%s' referenced in:\n",
|
"Unresolved external '%s' referenced in:\n",
|
||||||
GetString (E->Name));
|
name);
|
||||||
while (Imp) {
|
while (Imp) {
|
||||||
unsigned J;
|
unsigned J;
|
||||||
for (J = 0; J < CollCount (&Imp->RefLines); ++J) {
|
for (J = 0; J < CollCount (&Imp->RefLines); ++J) {
|
||||||
const LineInfo* LI = CollConstAt (&Imp->RefLines, J);
|
const LineInfo* LI = CollConstAt (&Imp->RefLines, J);
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
" %s(%u)\n",
|
" %s:%u: Error: Unresolved external '%s'\n",
|
||||||
GetSourceName (LI),
|
GetSourceName (LI),
|
||||||
GetSourceLine (LI));
|
GetSourceLine (LI),
|
||||||
|
name);
|
||||||
}
|
}
|
||||||
Imp = Imp->Next;
|
Imp = Imp->Next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ void CfgWarning (const FilePos* Pos, const char* Format, ...)
|
||||||
SB_VPrintf (&Buf, Format, ap);
|
SB_VPrintf (&Buf, Format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
Warning ("%s(%u): %s",
|
Warning ("%s:%u: %s",
|
||||||
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
|
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
|
||||||
SB_Done (&Buf);
|
SB_Done (&Buf);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ void CfgError (const FilePos* Pos, const char* Format, ...)
|
||||||
SB_VPrintf (&Buf, Format, ap);
|
SB_VPrintf (&Buf, Format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
Error ("%s(%u): %s",
|
Error ("%s:%u: %s",
|
||||||
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
|
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
|
||||||
SB_Done (&Buf);
|
SB_Done (&Buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user