diff --git a/include/util.hpp b/include/util.hpp index 25568416..a26dd393 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -14,6 +14,7 @@ bool isWhitespace(int c); bool isNewline(int c); +bool isPrintable(int c); bool startsIdentifier(int c); bool continuesIdentifier(int c); diff --git a/src/asm/actions.cpp b/src/asm/actions.cpp index 5fd37a30..52f36ece 100644 --- a/src/asm/actions.cpp +++ b/src/asm/actions.cpp @@ -594,9 +594,9 @@ std::string act_SectionName(std::string const &symName) { Symbol *sym = sym_FindScopedValidSymbol(symName); if (!sym) { if (sym_IsPurgedScoped(symName)) { - fatal("Unknown symbol \"%s\"; it was purged", symName.c_str()); + fatal("Undefined symbol \"%s\"; it was purged", symName.c_str()); } else { - fatal("Unknown symbol \"%s\"", symName.c_str()); + fatal("Undefined symbol \"%s\"", symName.c_str()); } } diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index efecce4b..e3ffa9db 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -370,9 +370,9 @@ void fstk_RunMacro(std::string const ¯oName, std::shared_ptr macr if (!macro) { if (sym_IsPurgedExact(macroName)) { - error("Macro \"%s\" not defined; it was purged", macroName.c_str()); + error("Undefined macro \"%s\"; it was purged", macroName.c_str()); } else { - error("Macro \"%s\" not defined", macroName.c_str()); + error("Undefined macro \"%s\"", macroName.c_str()); } return; } diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 15223a51..2b0019f1 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -579,7 +579,7 @@ static uint32_t readBracketedMacroArgNum() { c = bumpChar(); if (c != '>') { - error("Invalid character in bracketed macro argument %s", printChar(c)); + error("Invalid character %s in bracketed macro argument", printChar(c)); return 0; } else if (empty) { error("Empty bracketed macro argument"); @@ -911,7 +911,7 @@ static void discardLineContinuation() { error("Invalid line continuation at end of file"); break; } else { - error("Invalid character after line continuation %s", printChar(c)); + error("Invalid character %s after line continuation", printChar(c)); break; } } @@ -1568,17 +1568,19 @@ static bool isGarbageCharacter(int c) { static void reportGarbageCharacters(int c) { // '#' can be garbage if it doesn't start a raw string or identifier assume(isGarbageCharacter(c) || c == '#'); + bool isAscii = isPrintable(c); if (isGarbageCharacter(peek())) { // At least two characters are garbage; group them into one error report std::string garbage = printChar(c); while (isGarbageCharacter(peek())) { c = bumpChar(); + isAscii &= isPrintable(c); garbage += ", "; garbage += printChar(c); } - error("Unknown characters %s", garbage.c_str()); + error("Invalid characters %s%s", garbage.c_str(), isAscii ? "" : " (is the file UTF-8?)"); } else { - error("Unknown character %s", printChar(c)); + error("Invalid character %s%s", printChar(c), isAscii ? "" : " (is the file UTF-8?)"); } } diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp index 4dc23a8c..ca37cb3d 100644 --- a/src/asm/symbol.cpp +++ b/src/asm/symbol.cpp @@ -284,9 +284,9 @@ void sym_Purge(std::string const &symName) { if (!sym) { if (sym_IsPurgedScoped(symName)) { - error("'%s' was already purged", symName.c_str()); + error("Undefined symbol '%s' was already purged", symName.c_str()); } else { - error("'%s' not defined", symName.c_str()); + error("Undefined symbol '%s'", symName.c_str()); } } else if (sym->isBuiltin) { error("Built-in symbol '%s' cannot be purged", symName.c_str()); diff --git a/src/link/layout.cpp b/src/link/layout.cpp index 32fcee38..072b439d 100644 --- a/src/link/layout.cpp +++ b/src/link/layout.cpp @@ -223,7 +223,7 @@ void layout_PlaceSection(std::string const &name, bool isOptional) { Section *section = sect_GetSection(name.c_str()); if (!section) { if (!isOptional) { - lexer_Error("Unknown section \"%s\"", name.c_str()); + lexer_Error("Undefined section \"%s\"", name.c_str()); } return; } diff --git a/src/link/patch.cpp b/src/link/patch.cpp index 06ae7429..d4bdee45 100644 --- a/src/link/patch.cpp +++ b/src/link/patch.cpp @@ -277,7 +277,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) { errorAt( patch, - "Requested BANK() of symbol \"%s\", which was not found", + "Requested BANK() of undefined symbol \"%s\"", fileSymbols[value].name.c_str() ); isError = true; @@ -302,7 +302,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil while (getRPNByte(expression, size, patch)) {} if (Section const *sect = sect_GetSection(name); !sect) { - errorAt(patch, "Requested BANK() of section \"%s\", which was not found", name); + errorAt(patch, "Requested BANK() of undefined section \"%s\"", name); isError = true; value = 1; } else { @@ -327,7 +327,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil while (getRPNByte(expression, size, patch)) {} if (Section const *sect = sect_GetSection(name); !sect) { - errorAt(patch, "Requested SIZEOF() of section \"%s\", which was not found", name); + errorAt(patch, "Requested SIZEOF() of undefined section \"%s\"", name); isError = true; value = 1; } else { @@ -342,7 +342,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil while (getRPNByte(expression, size, patch)) {} if (Section const *sect = sect_GetSection(name); !sect) { - errorAt(patch, "Requested STARTOF() of section \"%s\", which was not found", name); + errorAt(patch, "Requested STARTOF() of undefined section \"%s\"", name); isError = true; value = 1; } else { @@ -427,7 +427,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil isError = true; } } else if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) { - errorAt(patch, "Unknown symbol \"%s\"", fileSymbols[value].name.c_str()); + errorAt(patch, "Undefined symbol \"%s\"", fileSymbols[value].name.c_str()); sym_DumpLocalAliasedSymbols(fileSymbols[value].name); isError = true; } else if (std::holds_alternative