Make quote marks consistent in error/warning messages (#1791)

- "Double quotes" for strings (filenames, section names, CLI option arguments, etc)
- 'Single quotes' for characters and CLI option flags
- `Backticks` for keywords and identifiers (symbol names, charmap names, etc)

CLI option flags also have their leading dashes
This commit is contained in:
Rangi
2025-08-12 15:24:21 -04:00
committed by GitHub
parent 7df9c12a6c
commit 7b405513d9
185 changed files with 889 additions and 877 deletions

View File

@@ -59,7 +59,7 @@ void layout_SetSectionType(SectionType type, uint32_t bank) {
if (bank < typeInfo.firstBank) {
lexer_Error(
"%s bank %" PRIu32 " doesn't exist (the minimum is %" PRIu32 ")",
"%s bank %" PRIu32 " does not exist (the minimum is %" PRIu32 ")",
typeInfo.name.c_str(),
bank,
typeInfo.firstBank
@@ -67,7 +67,7 @@ void layout_SetSectionType(SectionType type, uint32_t bank) {
bank = typeInfo.firstBank;
} else if (bank > typeInfo.lastBank) {
lexer_Error(
"%s bank %" PRIu32 " doesn't exist (the maximum is %" PRIu32 ")",
"%s bank %" PRIu32 " does not exist (the maximum is %" PRIu32 ")",
typeInfo.name.c_str(),
bank,
typeInfo.lastBank
@@ -243,7 +243,7 @@ void layout_PlaceSection(std::string const &name, bool isOptional) {
// A section that lacks data can only be assigned to a type that requires data
// if it's empty.
lexer_Error(
"\"%s\" is specified to be a %s section, but it doesn't contain data",
"\"%s\" is specified to be a %s section, but it does not contain data",
name.c_str(),
typeInfo.name.c_str()
);

View File

@@ -119,7 +119,7 @@ static yy::parser::symbol_type parseBinNumber(char const *prefix) {
LexerStackEntry &context = lexerStack.back();
int c = context.file.sgetc();
if (!isBinDigit(c)) {
lexer_Error("No binary digits found after '%s'", prefix);
lexer_Error("No binary digits found after %s", prefix);
return yy::parser::make_number(0);
}
@@ -142,7 +142,7 @@ static yy::parser::symbol_type parseOctNumber(char const *prefix) {
LexerStackEntry &context = lexerStack.back();
int c = context.file.sgetc();
if (!isOctDigit(c)) {
lexer_Error("No octal digits found after '%s'", prefix);
lexer_Error("No octal digits found after %s", prefix);
return yy::parser::make_number(0);
}
@@ -177,7 +177,7 @@ static yy::parser::symbol_type parseHexNumber(char const *prefix) {
LexerStackEntry &context = lexerStack.back();
int c = context.file.sgetc();
if (!isHexDigit(c)) {
lexer_Error("No hexadecimal digits found after '%s'", prefix);
lexer_Error("No hexadecimal digits found after %s", prefix);
return yy::parser::make_number(0);
}
@@ -198,22 +198,22 @@ static yy::parser::symbol_type parseNumber(int c) {
switch (context.file.sgetc()) {
case 'x':
context.file.sbumpc();
return parseHexNumber("0x");
return parseHexNumber("\"0x\"");
case 'X':
context.file.sbumpc();
return parseHexNumber("0X");
return parseHexNumber("\"0X\"");
case 'o':
context.file.sbumpc();
return parseOctNumber("0o");
return parseOctNumber("\"0o\"");
case 'O':
context.file.sbumpc();
return parseOctNumber("0O");
return parseOctNumber("\"0O\"");
case 'b':
context.file.sbumpc();
return parseBinNumber("0b");
return parseBinNumber("\"0b\"");
case 'B':
context.file.sbumpc();
return parseBinNumber("0B");
return parseBinNumber("\"0B");
}
}
return parseDecNumber(c);
@@ -284,11 +284,11 @@ yy::parser::symbol_type yylex() {
} else if (c == '"') {
return parseString();
} else if (c == '$') {
return parseHexNumber("$");
return parseHexNumber("'$'");
} else if (c == '%') {
return parseBinNumber("%");
return parseBinNumber("'%'");
} else if (c == '&') {
return parseOctNumber("&");
return parseOctNumber("'&'");
} else if (isDecDigit(c)) {
return parseNumber(c);
} else if (isIdentChar(c)) { // Note that we match these *after* digit characters!
@@ -320,7 +320,7 @@ yy::parser::symbol_type yylex() {
return search->second();
}
lexer_Error("Unknown keyword \"%s\"", ident.c_str());
lexer_Error("Unknown keyword `%s`", ident.c_str());
return yylex();
} else {
lexer_Error("Unexpected character %s", printChar(c));

View File

@@ -206,7 +206,7 @@ static void parseScrambleSpec(char *spec) {
spec = regionName + regionNameSkipLen;
if (*spec != '=' && *spec != ',' && *spec != '\0') {
fatal("Unexpected character %s in spec for option 'S'", printChar(*spec));
fatal("Unexpected character %s in spec for option '-S'", printChar(*spec));
}
char *regionSize = nullptr;
@@ -225,7 +225,7 @@ static void parseScrambleSpec(char *spec) {
spec = regionSize + regionSizeSkipLen;
if (*spec != ',' && *spec != '\0') {
fatal("Unexpected character %s in spec for option 'S'", printChar(*spec));
fatal("Unexpected character %s in spec for option '-S'", printChar(*spec));
}
}
@@ -248,16 +248,16 @@ static void parseScrambleSpec(char *spec) {
// and whitespace before the next iteration, we guarantee that the region name will not be
// empty if it is present at all.
if (*regionName == '\0') {
fatal("Empty region name in spec for option 'S'");
fatal("Empty region name in spec for option '-S'");
}
if (regionSize && *regionSize == '\0') {
fatal("Empty region size limit in spec for option 'S'");
fatal("Empty region size limit in spec for option '-S'");
}
// Determine which region type this is.
auto search = scrambleSpecs.find(regionName);
if (search == scrambleSpecs.end()) {
fatal("Unknown region name \"%s\" in spec for option 'S'", regionName);
fatal("Unknown region name \"%s\" in spec for option '-S'", regionName);
}
uint16_t limit = search->second.second;
@@ -266,11 +266,11 @@ static void parseScrambleSpec(char *spec) {
unsigned long value = strtoul(regionSize, &endptr, 0);
if (*endptr != '\0') {
fatal("Invalid region size limit \"%s\" for option 'S'", regionSize);
fatal("Invalid region size limit \"%s\" for option '-S'", regionSize);
}
if (value > limit) {
fatal(
"%s region size for option 'S' must be between 0 and %" PRIu16,
"%s region size for option '-S' must be between 0 and %" PRIu16,
search->first.c_str(),
limit
);
@@ -279,11 +279,11 @@ static void parseScrambleSpec(char *spec) {
limit = value;
} else if (search->second.first != &options.scrambleWRAMX) {
// Only WRAMX limit can be implied, since ROMX and SRAM size may vary.
fatal("Missing %s region size limit for option 'S'", search->first.c_str());
fatal("Missing %s region size limit for option '-S'", search->first.c_str());
}
if (*search->second.first != limit && *search->second.first != 0) {
warnx("Overriding %s region size limit for option 'S'", search->first.c_str());
warnx("Overriding %s region size limit for option '-S'", search->first.c_str());
}
// Update the scrambling region size limit.
@@ -303,10 +303,10 @@ int main(int argc, char *argv[]) {
char *endptr;
warnings.traceDepth = strtoul(musl_optarg, &endptr, 0);
if (musl_optarg[0] == '\0' || *endptr != '\0') {
fatal("Invalid argument for option 'B'");
fatal("Invalid argument for option '-B'");
}
if (warnings.traceDepth >= UINT64_MAX) {
fatal("Argument for option 'B' is too large");
fatal("Argument for option '-B' is too large");
}
break;
}
@@ -318,7 +318,7 @@ int main(int argc, char *argv[]) {
usage.printAndExit(0); // LCOV_EXCL_LINE
case 'l':
if (linkerScriptName) {
warnx("Overriding linker script %s", linkerScriptName);
warnx("Overriding linker script file \"%s\"", linkerScriptName);
}
linkerScriptName = musl_optarg;
break;
@@ -327,25 +327,25 @@ int main(int argc, char *argv[]) {
break;
case 'm':
if (options.mapFileName) {
warnx("Overriding map file %s", options.mapFileName);
warnx("Overriding map file \"%s\"", options.mapFileName);
}
options.mapFileName = musl_optarg;
break;
case 'n':
if (options.symFileName) {
warnx("Overriding sym file %s", options.symFileName);
warnx("Overriding sym file \"%s\"", options.symFileName);
}
options.symFileName = musl_optarg;
break;
case 'O':
if (options.overlayFileName) {
warnx("Overriding overlay file %s", options.overlayFileName);
warnx("Overriding overlay file \"%s\"", options.overlayFileName);
}
options.overlayFileName = musl_optarg;
break;
case 'o':
if (options.outputFileName) {
warnx("Overriding output file %s", options.outputFileName);
warnx("Overriding output file \"%s\"", options.outputFileName);
}
options.outputFileName = musl_optarg;
break;
@@ -354,10 +354,10 @@ int main(int argc, char *argv[]) {
unsigned long value = strtoul(musl_optarg, &endptr, 0);
if (musl_optarg[0] == '\0' || *endptr != '\0') {
fatal("Invalid argument for option 'p'");
fatal("Invalid argument for option '-p'");
}
if (value > 0xFF) {
fatal("Argument for option 'p' must be between 0 and 0xFF");
fatal("Argument for option '-p' must be between 0 and 0xFF");
}
options.padValue = value;
@@ -410,7 +410,7 @@ int main(int argc, char *argv[]) {
verboseOutputConfig(argc, argv);
if (musl_optind == argc) {
usage.printAndExit("No input file specified (pass `-` to read from standard input)");
usage.printAndExit("No input file specified (pass \"-\" to read from standard input)");
}
// Patch the size array depending on command-line options

View File

@@ -125,7 +125,7 @@ static void readFileStackNode(
uint32_t depth;
case NODE_REPT:
tryReadLong(
depth, file, "%s: Cannot read node #%" PRIu32 "'s rept depth: %s", fileName, nodeID
depth, file, "%s: Cannot read node #%" PRIu32 "'s REPT depth: %s", fileName, nodeID
);
node.data = std::vector<uint32_t>(depth);
for (uint32_t i = 0; i < depth; ++i) {
@@ -140,7 +140,7 @@ static void readFileStackNode(
}
if (!node.parent) {
fatal(
"%s is not a valid object file: root node (#%" PRIu32 ") may not be REPT",
"%s: Invalid object file: root node (#%" PRIu32 ") may not be REPT",
fileName,
nodeID
);
@@ -157,7 +157,7 @@ static void readSymbol(
ExportLevel,
symbol.type,
file,
"%s: Cannot read \"%s\"'s type: %s",
"%s: Cannot read `%s`'s type: %s",
fileName,
symbol.name.c_str()
);
@@ -165,27 +165,21 @@ static void readSymbol(
if (symbol.type != SYMTYPE_IMPORT) {
uint32_t nodeID;
tryReadLong(
nodeID, file, "%s: Cannot read \"%s\"'s node ID: %s", fileName, symbol.name.c_str()
nodeID, file, "%s: Cannot read `%s`'s node ID: %s", fileName, symbol.name.c_str()
);
symbol.src = &fileNodes[nodeID];
tryReadLong(
symbol.lineNo,
file,
"%s: Cannot read \"%s\"'s line number: %s",
"%s: Cannot read `%s`'s line number: %s",
fileName,
symbol.name.c_str()
);
int32_t sectionID, value;
tryReadLong(
sectionID,
file,
"%s: Cannot read \"%s\"'s section ID: %s",
fileName,
symbol.name.c_str()
);
tryReadLong(
value, file, "%s: Cannot read \"%s\"'s value: %s", fileName, symbol.name.c_str()
sectionID, file, "%s: Cannot read `%s`'s section ID: %s", fileName, symbol.name.c_str()
);
tryReadLong(value, file, "%s: Cannot read `%s`'s value: %s", fileName, symbol.name.c_str());
if (sectionID == -1) {
symbol.data = value;
} else {

View File

@@ -277,7 +277,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) {
errorAt(
patch,
"Requested BANK() of undefined symbol \"%s\"",
"Requested `BANK()` of undefined symbol `%s`",
fileSymbols[value].name.c_str()
);
isError = true;
@@ -287,7 +287,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
} else {
errorAt(
patch,
"Requested BANK() of non-label symbol \"%s\"",
"Requested `BANK()` of non-label symbol `%s`",
fileSymbols[value].name.c_str()
);
isError = true;
@@ -302,7 +302,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
while (getRPNByte(expression, size, patch)) {}
if (Section const *sect = sect_GetSection(name); !sect) {
errorAt(patch, "Requested BANK() of undefined section \"%s\"", 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<Symbol> const &fil
while (getRPNByte(expression, size, patch)) {}
if (Section const *sect = sect_GetSection(name); !sect) {
errorAt(patch, "Requested SIZEOF() of undefined section \"%s\"", 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<Symbol> const &fil
while (getRPNByte(expression, size, patch)) {}
if (Section const *sect = sect_GetSection(name); !sect) {
errorAt(patch, "Requested STARTOF() of undefined section \"%s\"", name);
errorAt(patch, "Requested `STARTOF()` of undefined section \"%s\"", name);
isError = true;
value = 1;
} else {
@@ -355,7 +355,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_SIZEOF_SECTTYPE:
value = getRPNByte(expression, size, patch);
if (value < 0 || value >= SECTTYPE_INVALID) {
errorAt(patch, "Requested SIZEOF() an invalid section type");
errorAt(patch, "Requested `SIZEOF()` of an invalid section type");
isError = true;
value = 0;
} else {
@@ -366,7 +366,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
case RPN_STARTOF_SECTTYPE:
value = getRPNByte(expression, size, patch);
if (value < 0 || value >= SECTTYPE_INVALID) {
errorAt(patch, "Requested STARTOF() an invalid section type");
errorAt(patch, "Requested `STARTOF()` of an invalid section type");
isError = true;
value = 0;
} else {
@@ -379,7 +379,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
if (value < 0xFF00 || value > 0xFFFF) {
firstErrorAt(
patch,
"Address $%" PRIx32 " for LDH is not in HRAM range; use LD instead",
"Address $%" PRIx32 " for `LDH` is not in HRAM range; use `LD` instead",
value
);
value = 0;
@@ -392,7 +392,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
// Acceptable values are 0x00, 0x08, 0x10, ..., 0x38
if (value & ~0x38) {
firstErrorAt(
patch, "Value $%" PRIx32 " is not a RST vector; use CALL instead", value
patch, "Value $%" PRIx32 " is not a `RST` vector; use `CALL` instead", value
);
value = 0;
}
@@ -433,7 +433,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
isError = true;
}
} else if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) {
errorAt(patch, "Undefined symbol \"%s\"", fileSymbols[value].name.c_str());
errorAt(patch, "Undefined symbol `%s`", fileSymbols[value].name.c_str());
sym_TraceLocalAliasedSymbols(fileSymbols[value].name);
isError = true;
} else if (std::holds_alternative<Label>(symbol->data)) {
@@ -538,8 +538,8 @@ static void applyFilePatches(Section &section, Section &dataSection) {
if (jumpOffset < -128 || jumpOffset > 127) {
firstErrorAt(
patch,
"JR target must be between -128 and 127 bytes away, not %" PRId16
"; use JP instead",
"`JR` target must be between -128 and 127 bytes away, not %" PRId16
"; use `JP` instead",
jumpOffset
);
}

View File

@@ -120,7 +120,7 @@ static void mergeSections(Section &target, std::unique_ptr<Section> &&other) {
fatalTwoAt(
target,
*other,
"Section \"%s\" is defined as SECTION %s, but also as SECTION %s",
"Section \"%s\" is defined as `SECTION %s`, but also as `SECTION %s`",
target.name.c_str(),
sectionModNames[target.modifier],
sectionModNames[other->modifier]
@@ -131,7 +131,7 @@ static void mergeSections(Section &target, std::unique_ptr<Section> &&other) {
fatalTwoAt(
target,
*other,
"Section \"%s\" is defined with type %s, but also with type %s",
"Section \"%s\" is defined with type `%s`, but also with type `%s`",
target.name.c_str(),
sectionTypeInfo[target.type].name.c_str(),
sectionTypeInfo[other->type].name.c_str()
@@ -197,7 +197,7 @@ void sect_AddSection(std::unique_ptr<Section> &&section) {
mergeSections(*target, std::move(section));
} else if (section->modifier == SECTION_UNION && sect_HasData(section->type)) {
fatal(
"Section \"%s\" is of type %s, which cannot be unionized",
"Section \"%s\" is of type `%s`, which cannot be `UNION`ized",
section->name.c_str(),
sectionTypeInfo[section->type].name.c_str()
);
@@ -227,7 +227,7 @@ static void doSanityChecks(Section &section) {
if (options.is32kMode && section.type == SECTTYPE_ROMX) {
if (section.isBankFixed && section.bank != 1) {
error(
"Section \"%s\" has type ROMX, which must be in bank 1 (if any) with option `-t`",
"Section \"%s\" has type `ROMX`, which must be in bank 1 (if any) with option '-t'",
section.name.c_str()
);
} else {
@@ -237,7 +237,8 @@ static void doSanityChecks(Section &section) {
if (options.isWRAM0Mode && section.type == SECTTYPE_WRAMX) {
if (section.isBankFixed && section.bank != 1) {
error(
"Section \"%s\" has type WRAMX, which must be in bank 1 with options `-w` or `-d`",
"Section \"%s\" has type `WRAMX`, which must be in bank 1 with options '-w' or "
"'-d'",
section.name.c_str()
);
} else {
@@ -246,7 +247,7 @@ static void doSanityChecks(Section &section) {
}
if (options.isDmgMode && section.type == SECTTYPE_VRAM && section.bank == 1) {
error(
"Section \"%s\" has type VRAM, which must be in bank 0 with option `-d`",
"Section \"%s\" has type `VRAM`, which must be in bank 0 with option '-d'",
section.name.c_str()
);
}
@@ -260,7 +261,7 @@ static void doSanityChecks(Section &section) {
// Too large an alignment may not be satisfiable
if (section.isAlignFixed && (section.alignMask & sectionTypeInfo[section.type].startAddr)) {
error(
"Section \"%s\" has type %s, which cannot be aligned to $%04x bytes",
"Section \"%s\" has type `%s`, which cannot be aligned to $%04x bytes",
section.name.c_str(),
sectionTypeInfo[section.type].name.c_str(),
section.alignMask + 1
@@ -305,7 +306,7 @@ static void doSanityChecks(Section &section) {
if (section.isAlignFixed) {
if ((section.org & section.alignMask) != section.alignOfs) {
error(
"Section \"%s\"'s fixed address doesn't match its alignment",
"Section \"%s\"'s fixed address does not match its alignment",
section.name.c_str()
);
}

View File

@@ -44,7 +44,7 @@ void sym_AddSymbol(Symbol &symbol) {
fatalTwoAt(
symbol,
*other,
"\"%s\" is defined as %s, but also as %s",
"`%s` is defined as %s, but also as %s",
symbol.name.c_str(),
symDef.c_str(),
otherDef.c_str()