Support colors in diagnostic output.

This commit is contained in:
Kugel Fuhr
2025-07-09 14:21:14 +02:00
parent 96f8ce4cee
commit 79967ff01b
21 changed files with 377 additions and 148 deletions

View File

@@ -167,13 +167,13 @@ Import* ReadImport (FILE* F, ObjData* Obj)
*/
if (ObjHasFiles (I->Obj)) {
const LineInfo* LI = GetImportPos (I);
Error ("Invalid import size in for '%s', imported from %s:%u: 0x%02X",
Error ("Invalid import size in for `%s', imported from %s:%u: 0x%02X",
GetString (I->Name),
GetSourceName (LI),
GetSourceLine (LI),
I->AddrSize);
} else {
Error ("Invalid import size in for '%s', imported from %s: 0x%02X",
Error ("Invalid import size in for `%s', imported from %s: 0x%02X",
GetString (I->Name),
GetObjFileName (I->Obj),
I->AddrSize);
@@ -200,7 +200,7 @@ Import* GenImport (unsigned Name, unsigned char AddrSize)
/* We have no object file information and no line info for a new
** import
*/
Error ("Invalid import size 0x%02X for symbol '%s'",
Error ("Invalid import size 0x%02X for symbol `%s'",
I->AddrSize,
GetString (I->Name));
}
@@ -484,7 +484,7 @@ void InsertExport (Export* E)
}
} else if (AllowMultDef == 0) {
/* Duplicate entry, this is fatal unless allowed by the user */
Error ("Duplicate external identifier: '%s'",
Error ("Duplicate external identifier: `%s'",
GetString (L->Name));
}
return;
@@ -663,7 +663,7 @@ long GetExportVal (const Export* E)
{
if (E->Expr == 0) {
/* OOPS */
Internal ("'%s' is an undefined external", GetString (E->Name));
Internal ("`%s' is an undefined external", GetString (E->Name));
}
return GetExprVal (E->Expr);
}
@@ -726,9 +726,9 @@ static void CheckSymType (const Export* E)
}
/* Output the diagnostic */
Warning ("Address size mismatch for '%s': "
"Exported from %s as '%s', "
"import in %s as '%s'",
Warning ("Address size mismatch for `%s': "
"Exported from %s as `%s', "
"import in %s as `%s'",
GetString (E->Name),
SB_GetConstBuf (&ExportLoc),
ExpAddrSize,
@@ -775,21 +775,20 @@ 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);
const char* Name = GetString (E->Name);
while (Imp) {
unsigned J, count = CollCount (&Imp->RefLines);
/* The count is 0 when the import was not added by an input file,
but by the compiler itself. */
if (count == 0) {
fprintf (stderr, "Error: Unresolved external '%s'\n", name);
unsigned J, Count = CollCount (&Imp->RefLines);
/* The count is 0 when the import was not added by an input
** file, but by the compiler itself.
*/
if (Count == 0) {
Warning ("Unresolved external `%s'", Name);
} else {
for (J = 0; J < count; ++J) {
for (J = 0; J < Count; ++J) {
const LineInfo* LI = CollConstAt (&Imp->RefLines, J);
fprintf (stderr,
"%s:%u: Error: Unresolved external '%s'\n",
GetSourceName (LI),
GetSourceLine (LI),
name);
CfgWarning (GetSourcePos (LI),
"Unresolved external `%s'",
Name);
}
}
Imp = Imp->Next;
@@ -1080,7 +1079,7 @@ void CircularRefError (const Export* E)
/* Print an error about a circular reference using to define the given export */
{
const LineInfo* LI = GetExportPos (E);
Error ("Circular reference for symbol '%s', %s:%u",
Error ("Circular reference for symbol `%s', %s:%u",
GetString (E->Name),
GetSourceName (LI),
GetSourceLine (LI));