1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +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:
Andrea Odetti 2021-05-10 09:56:40 +01:00 committed by Oliver Schmidt
parent bda5bf70ce
commit bcc670ee36
9 changed files with 22 additions and 20 deletions

View File

@ -84,7 +84,7 @@ static void VPrintMsg (const FilePos* Pos, const char* Desc,
SB_Terminate (&Msg);
/* Format the message header */
SB_Printf (&S, "%s(%u): %s: ",
SB_Printf (&S, "%s:%u: %s: ",
SB_GetConstBuf (GetFileName (Pos->Name)),
Pos->Line,
Desc);

View File

@ -129,7 +129,7 @@ void Fatal (const char* Format, ...)
LineNum = GetCurrentLine ();
}
fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum);
fprintf (stderr, "%s:%u: Fatal: ", FileName, LineNum);
va_start (ap, Format);
vfprintf (stderr, Format, ap);
@ -159,7 +159,7 @@ void Internal (const char* Format, ...)
LineNum = GetCurrentLine ();
}
fprintf (stderr, "%s(%u): Internal compiler error:\n",
fprintf (stderr, "%s:%u: Internal compiler error:\n",
FileName, LineNum);
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)
/* Print an error message - internal function*/
{
fprintf (stderr, "%s(%u): Error: ", Filename, LineNo);
fprintf (stderr, "%s:%u: Error: ", Filename, LineNo);
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");
@ -250,7 +250,7 @@ static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg,
} else if (IS_Get (&WarnEnable)) {
fprintf (stderr, "%s(%u): Warning: ", Filename, LineNo);
fprintf (stderr, "%s:%u: Warning: ", Filename, LineNo);
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");

View File

@ -784,7 +784,7 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
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);
}

View File

@ -1396,7 +1396,7 @@ void Preprocess (void)
Done:
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));
}
}

View File

@ -133,7 +133,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
SB_Terminate (&Ident);
} else {
if (!IgnoreUnknown) {
Error ("%s(%u): Syntax error", Filename, Line);
Error ("%s:%u: Syntax error", Filename, Line);
}
continue;
}
@ -148,7 +148,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
++L;
} else {
if (!IgnoreUnknown) {
Error ("%s(%u): Missing '='", Filename, Line);
Error ("%s:%u: Missing '='", Filename, Line);
}
continue;
}
@ -192,7 +192,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
/* Must have at least one digit */
if (Digits == 0) {
if (!IgnoreUnknown) {
Error ("%s(%u): Error in number format", Filename, Line);
Error ("%s:%u: Error in number format", Filename, Line);
}
continue;
}
@ -213,7 +213,7 @@ void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown)
/* Check for a comment character or end of line */
if (*L != CommentStart && *L != '\0') {
if (!IgnoreUnknown) {
Error ("%s(%u): Trailing garbage", Filename, Line);
Error ("%s:%u: Trailing garbage", Filename, Line);
}
continue;
}

View File

@ -94,7 +94,7 @@ void InfoWarning (const char* Format, ...)
xvsprintf (Buf, sizeof (Buf), Format, ap);
va_end (ap);
fprintf (stderr, "%s(%u): Warning: %s\n",
fprintf (stderr, "%s:%u: Warning: %s\n",
InputSrcName, InfoErrorLine, Buf);
}
@ -110,7 +110,7 @@ void InfoError (const char* Format, ...)
xvsprintf (Buf, sizeof (Buf), Format, ap);
va_end (ap);
fprintf (stderr, "%s(%u): Error: %s\n",
fprintf (stderr, "%s:%u: Error: %s\n",
InputSrcName, InfoErrorLine, Buf);
exit (EXIT_FAILURE);
}

View File

@ -140,12 +140,12 @@ void CheckAssertions (void)
case ASSERT_ACT_WARN:
case ASSERT_ACT_LDWARN:
Warning ("%s(%u): %s", Module, Line, Message);
Warning ("%s:%u: %s", Module, Line, Message);
break;
case ASSERT_ACT_ERROR:
case ASSERT_ACT_LDERROR:
Error ("%s(%u): %s", Module, Line, Message);
Error ("%s:%u: %s", Module, Line, Message);
break;
default:

View File

@ -774,17 +774,19 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data)
if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) {
/* Unresolved external */
Import* Imp = E->ImpList;
const char * name = GetString (E->Name);
fprintf (stderr,
"Unresolved external '%s' referenced in:\n",
GetString (E->Name));
name);
while (Imp) {
unsigned J;
for (J = 0; J < CollCount (&Imp->RefLines); ++J) {
const LineInfo* LI = CollConstAt (&Imp->RefLines, J);
fprintf (stderr,
" %s(%u)\n",
" %s:%u: Error: Unresolved external '%s'\n",
GetSourceName (LI),
GetSourceLine (LI));
GetSourceLine (LI),
name);
}
Imp = Imp->Next;
}

View File

@ -92,7 +92,7 @@ void CfgWarning (const FilePos* Pos, const char* Format, ...)
SB_VPrintf (&Buf, Format, ap);
va_end (ap);
Warning ("%s(%u): %s",
Warning ("%s:%u: %s",
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
SB_Done (&Buf);
}
@ -109,7 +109,7 @@ void CfgError (const FilePos* Pos, const char* Format, ...)
SB_VPrintf (&Buf, Format, ap);
va_end (ap);
Error ("%s(%u): %s",
Error ("%s:%u: %s",
GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf));
SB_Done (&Buf);
}