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

@@ -27,11 +27,11 @@ void act_If(int32_t condition) {
void act_Elif(int32_t condition) {
if (lexer_GetIFDepth() == 0) {
fatal("Found ELIF outside of an IF construct");
fatal("Found `ELIF` outside of a conditional (not after an `IF`/`ELIF` block)");
}
if (lexer_RanIFBlock()) {
if (lexer_ReachedELSEBlock()) {
fatal("Found ELIF after an ELSE block");
fatal("Found `ELIF` after an `ELSE` block");
}
lexer_SetMode(LEXER_SKIP_TO_ENDC);
} else if (condition) {
@@ -43,11 +43,11 @@ void act_Elif(int32_t condition) {
void act_Else() {
if (lexer_GetIFDepth() == 0) {
fatal("Found ELSE outside of an IF construct");
fatal("Found `ELSE` outside of a conditional (not after an `IF`/`ELIF` block)");
}
if (lexer_RanIFBlock()) {
if (lexer_ReachedELSEBlock()) {
fatal("Found ELSE after an ELSE block");
fatal("Found `ELSE` after an `ELSE` block");
}
lexer_SetMode(LEXER_SKIP_TO_ENDC);
} else {
@@ -140,14 +140,16 @@ std::optional<std::string> act_ReadFile(std::string const &name, uint32_t maxLen
}
fseek(file, 0, SEEK_SET);
} else if (errno != ESPIPE) {
error("Error determining size of READFILE file '%s': %s", name.c_str(), strerror(errno));
error(
"Error determining size of `READFILE` file \"%s\": %s", name.c_str(), strerror(errno)
);
}
std::string contents;
contents.resize(readSize);
if (fread(&contents[0], 1, readSize, file) < readSize || ferror(file)) {
error("Error reading READFILE file '%s': %s", name.c_str(), strerror(errno));
error("Error reading `READFILE` file \"%s\": %s", name.c_str(), strerror(errno));
return "";
}
@@ -578,12 +580,13 @@ std::string act_StringFormat(
}
if (argIndex < args.size()) {
error("STRFMT: %zu unformatted argument(s)", args.size() - argIndex);
size_t extra = args.size() - argIndex;
error("STRFMT: %zu unformatted argument%s", extra, extra == 1 ? "" : "s");
} else if (argIndex > args.size()) {
error(
"STRFMT: Not enough arguments for format spec, got: %zu, need: %zu",
args.size(),
argIndex
"STRFMT: Not enough arguments for format spec (expected %zu, got %zu)",
argIndex,
args.size()
);
}
@@ -594,15 +597,15 @@ std::string act_SectionName(std::string const &symName) {
Symbol *sym = sym_FindScopedValidSymbol(symName);
if (!sym) {
if (sym_IsPurgedScoped(symName)) {
fatal("Undefined symbol \"%s\"; it was purged", symName.c_str());
fatal("Undefined symbol `%s`; it was purged", symName.c_str());
} else {
fatal("Undefined symbol \"%s\"", symName.c_str());
fatal("Undefined symbol `%s`", symName.c_str());
}
}
Section const *section = sym->getSection();
if (!section) {
fatal("\"%s\" does not belong to any section", sym->name.c_str());
fatal("`%s` does not belong to any section", sym->name.c_str());
}
return section->name;

View File

@@ -84,14 +84,14 @@ void charmap_New(std::string const &name, std::string const *baseName) {
if (baseName != nullptr) {
if (auto search = charmapMap.find(*baseName); search == charmapMap.end()) {
error("Base charmap '%s' doesn't exist", baseName->c_str());
error("Undefined base charmap `%s`", baseName->c_str());
} else {
baseIdx = search->second;
}
}
if (charmapMap.find(name) != charmapMap.end()) {
error("Charmap '%s' already exists", name.c_str());
error("Charmap `%s` is already defined", name.c_str());
return;
}
@@ -112,7 +112,7 @@ void charmap_New(std::string const &name, std::string const *baseName) {
void charmap_Set(std::string const &name) {
if (auto search = charmapMap.find(name); search == charmapMap.end()) {
error("Charmap '%s' doesn't exist", name.c_str());
error("Undefined charmap `%s`", name.c_str());
} else {
currentCharmap = &charmapList[search->second];
}
@@ -289,7 +289,7 @@ size_t charmap_ConvertNext(std::string_view &input, std::vector<int32_t> *output
} else if (charmap.name != DEFAULT_CHARMAP_NAME) {
warning(
WARNING_UNMAPPED_CHAR_2,
"Unmapped character %s not in " DEFAULT_CHARMAP_NAME " charmap",
"Unmapped character %s not in `" DEFAULT_CHARMAP_NAME "` charmap",
printChar(firstChar)
);
}

View File

@@ -227,8 +227,9 @@ bool yywrap() {
if (ifDepth != 0) {
fatal(
"Ended block with %" PRIu32 " unterminated IF construct%s",
"Ended block with %" PRIu32 " unterminated conditional%s (`IF`/`ELIF`/`ELSE` block%s)",
ifDepth,
ifDepth == 1 ? "" : "s",
ifDepth == 1 ? "" : "s"
);
}
@@ -255,7 +256,7 @@ bool yywrap() {
// This error message will refer to the current iteration
if (sym->type != SYM_VAR) {
fatal("Failed to update FOR symbol value");
fatal("Failed to update `FOR` symbol value");
}
}
// Advance to the next iteration
@@ -370,14 +371,14 @@ static Context &newReptContext(int32_t reptLineNo, ContentSpan const &span, uint
bool fstk_FileError(std::string const &path, char const *functionName) {
if (options.missingIncludeState == INC_ERROR) {
error("Error opening %s file '%s': %s", functionName, path.c_str(), strerror(errno));
error("Error opening `%s` file \"%s\": %s", functionName, path.c_str(), strerror(errno));
} else {
failedOnMissingInclude = true;
// LCOV_EXCL_START
if (options.missingIncludeState == GEN_EXIT) {
verbosePrint(
VERB_NOTICE,
"Aborting (-MG) on %s file '%s' (%s)\n",
"Aborting (-MG) on `%s` file \"%s\": %s\n",
functionName,
path.c_str(),
strerror(errno)
@@ -407,14 +408,14 @@ void fstk_RunMacro(std::string const &macroName, std::shared_ptr<MacroArgs> macr
if (!macro) {
if (sym_IsPurgedExact(macroName)) {
error("Undefined macro \"%s\"; it was purged", macroName.c_str());
error("Undefined macro `%s`; it was purged", macroName.c_str());
} else {
error("Undefined macro \"%s\"", macroName.c_str());
error("Undefined macro `%s`", macroName.c_str());
}
return;
}
if (macro->type != SYM_MACRO) {
error("\"%s\" is not a macro", macroName.c_str());
error("`%s` is not a macro", macroName.c_str());
return;
}
@@ -447,11 +448,13 @@ void fstk_RunFor(
} else if (step < 0 && stop < start) {
count = (static_cast<int64_t>(start) - stop - 1) / -static_cast<int64_t>(step) + 1;
} else if (step == 0) {
error("FOR cannot have a step value of 0");
error("`FOR` cannot have a step value of 0");
}
if ((step > 0 && start > stop) || (step < 0 && start < stop)) {
warning(WARNING_BACKWARDS_FOR, "FOR goes backwards from %d to %d by %d", start, stop, step);
warning(
WARNING_BACKWARDS_FOR, "`FOR` goes backwards from %d to %d by %d", start, stop, step
);
}
if (count == 0) {
@@ -467,7 +470,7 @@ void fstk_RunFor(
bool fstk_Break() {
if (contextStack.top().fileInfo->type != NODE_REPT) {
error("BREAK can only be used inside a REPT/FOR block");
error("`BREAK` can only be used inside a loop (`REPT`/`FOR` block)");
return false;
}
@@ -489,7 +492,7 @@ void fstk_Init(std::string const &mainPath) {
if (std::optional<std::string> fullPath = fstk_FindFile(name); fullPath) {
newFileContext(*fullPath, false);
} else {
error("Error reading pre-included file '%s': %s", name.c_str(), strerror(errno));
error("Error reading pre-included file \"%s\": %s", name.c_str(), strerror(errno));
}
}
}

View File

@@ -298,7 +298,7 @@ void lexer_IncIFDepth() {
void lexer_DecIFDepth() {
if (lexerState->ifStack.empty()) {
fatal("Found ENDC outside of an IF construct");
fatal("Found `ENDC` outside of a conditional (not after an `IF`/`ELIF`/`ELSE` block)");
}
lexerState->ifStack.pop_front();
@@ -472,7 +472,7 @@ size_t BufferedContent::readMore(size_t startIndex, size_t nbChars) {
if (nbReadChars == -1) {
// LCOV_EXCL_START
fatal("Error while reading \"%s\": %s", lexerState->path.c_str(), strerror(errno));
fatal("Error reading file \"%s\": %s", lexerState->path.c_str(), strerror(errno));
// LCOV_EXCL_STOP
}
@@ -560,14 +560,14 @@ static uint32_t readBracketedMacroArgNum() {
if (Symbol const *sym = sym_FindScopedValidSymbol(symName); !sym) {
if (sym_IsPurgedScoped(symName)) {
error("Bracketed symbol \"%s\" does not exist; it was purged", symName.c_str());
error("Bracketed symbol `%s` does not exist; it was purged", symName.c_str());
} else {
error("Bracketed symbol \"%s\" does not exist", symName.c_str());
error("Bracketed symbol `%s` does not exist", symName.c_str());
}
num = 0;
symbolError = true;
} else if (!sym->isNumeric()) {
error("Bracketed symbol \"%s\" is not numeric", symName.c_str());
error("Bracketed symbol `%s` is not numeric", symName.c_str());
num = 0;
symbolError = true;
} else {
@@ -585,7 +585,7 @@ static uint32_t readBracketedMacroArgNum() {
error("Empty bracketed macro argument");
return 0;
} else if (num == 0 && !symbolError) {
error("Invalid bracketed macro argument '\\<0>'");
error("Invalid bracketed macro argument \"\\<0>\"");
return 0;
} else {
return num;
@@ -596,13 +596,13 @@ static std::shared_ptr<std::string> readMacroArg() {
if (int c = bumpChar(); c == '@') {
std::shared_ptr<std::string> str = fstk_GetUniqueIDStr();
if (!str) {
error("'\\@' cannot be used outside of a macro or REPT/FOR block");
error("`\\@` cannot be used outside of a macro or loop (`REPT`/`FOR` block)");
}
return str;
} else if (c == '#') {
MacroArgs *macroArgs = fstk_GetCurrentMacroArgs();
if (!macroArgs) {
error("'\\#' cannot be used outside of a macro");
error("`\\#` cannot be used outside of a macro");
return nullptr;
}
@@ -618,13 +618,13 @@ static std::shared_ptr<std::string> readMacroArg() {
MacroArgs *macroArgs = fstk_GetCurrentMacroArgs();
if (!macroArgs) {
error("'\\<%" PRIu32 ">' cannot be used outside of a macro", num);
error("`\\<%" PRIu32 ">` cannot be used outside of a macro", num);
return nullptr;
}
std::shared_ptr<std::string> str = macroArgs->getArg(num);
if (!str) {
error("Macro argument '\\<%" PRId32 ">' not defined", num);
error("Macro argument `\\<%" PRId32 ">` not defined", num);
}
return str;
} else {
@@ -632,13 +632,13 @@ static std::shared_ptr<std::string> readMacroArg() {
MacroArgs *macroArgs = fstk_GetCurrentMacroArgs();
if (!macroArgs) {
error("'\\%c' cannot be used outside of a macro", c);
error("`\\%c` cannot be used outside of a macro", c);
return nullptr;
}
std::shared_ptr<std::string> str = macroArgs->getArg(c - '0');
if (!str) {
error("Macro argument '\\%c' not defined", c);
error("Macro argument `\\%c` not defined", c);
}
return str;
}
@@ -847,11 +847,11 @@ void lexer_TraceStringExpansions() {
// Only print EQUS expansions, not string args
if (exp.name) {
style_Set(stderr, STYLE_CYAN, false);
fputs(" while expanding symbol \"", stderr);
fputs(" while expanding symbol `", stderr);
style_Set(stderr, STYLE_CYAN, true);
fputs(exp.name->c_str(), stderr);
style_Set(stderr, STYLE_CYAN, false);
fputs("\"\n", stderr);
fputs("`\n", stderr);
}
}
style_Reset(stderr);
@@ -876,7 +876,7 @@ static void discardBlockComment() {
continue;
case '/':
if (peek() == '*') {
warning(WARNING_NESTED_COMMENT, "/* in block comment");
warning(WARNING_NESTED_COMMENT, "\"/*\" in block comment");
}
continue;
case '*':
@@ -1252,7 +1252,7 @@ static std::pair<Symbol const *, std::shared_ptr<std::string>> readInterpolation
}
continue; // Restart, reading from the new buffer
} else if (int c = peek(); c == EOF || isNewline(c) || c == '"') {
error("Missing }");
error("Missing '}'");
break;
} else if (c == '}') {
shiftChar();
@@ -1264,7 +1264,7 @@ static std::pair<Symbol const *, std::shared_ptr<std::string>> readInterpolation
}
fmt.finishCharacters();
if (!fmt.isValid()) {
error("Invalid format spec '%s'", fmtBuf.c_str());
error("Invalid format spec \"%s\"", fmtBuf.c_str());
}
fmtBuf.clear(); // Now that format has been set, restart at beginning of string
} else {
@@ -1279,7 +1279,7 @@ static std::pair<Symbol const *, std::shared_ptr<std::string>> readInterpolation
} else if (keywordDict.find(fmtBuf) != keywordDict.end()) {
// Don't allow symbols that alias keywords without a '#' prefix.
error(
"Interpolated symbol \"%s\" is a reserved keyword; add a '#' prefix to use it as a raw "
"Interpolated symbol `%s` is a reserved keyword; add a '#' prefix to use it as a raw "
"symbol",
fmtBuf.c_str()
);
@@ -1288,9 +1288,9 @@ static std::pair<Symbol const *, std::shared_ptr<std::string>> readInterpolation
if (Symbol const *sym = sym_FindScopedValidSymbol(fmtBuf); !sym || !sym->isDefined()) {
if (sym_IsPurgedScoped(fmtBuf)) {
error("Interpolated symbol \"%s\" does not exist; it was purged", fmtBuf.c_str());
error("Interpolated symbol `%s` does not exist; it was purged", fmtBuf.c_str());
} else {
error("Interpolated symbol \"%s\" does not exist", fmtBuf.c_str());
error("Interpolated symbol `%s` does not exist", fmtBuf.c_str());
}
return {sym, nullptr};
} else if (sym->type == SYM_EQUS) {
@@ -1302,7 +1302,7 @@ static std::pair<Symbol const *, std::shared_ptr<std::string>> readInterpolation
fmt.appendNumber(*buf, sym->getConstantValue());
return {sym, buf};
} else {
error("Interpolated symbol \"%s\" is not a numeric or string symbol", fmtBuf.c_str());
error("Interpolated symbol `%s` is not a numeric or string symbol", fmtBuf.c_str());
return {sym, nullptr};
}
}
@@ -1426,7 +1426,7 @@ static void appendCharInLiteral(std::string &str, int c) {
break;
case EOF: // Can't really print that one
error("Illegal character escape at end of input");
error("Illegal character escape '\\' at end of input");
str += '\\';
break;
@@ -2061,7 +2061,7 @@ backslash:
continue;
case EOF: // Can't really print that one
error("Illegal character escape at end of input");
error("Illegal character escape '\\' at end of input");
c = '\\';
break;
@@ -2173,7 +2173,7 @@ static Token skipIfBlock(bool toEndc) {
case T_(POP_ELIF):
if (lexer_ReachedELSEBlock()) {
// This should be redundant, as the parser handles this error first.
fatal("Found ELIF after an ELSE block"); // LCOV_EXCL_LINE
fatal("Found `ELIF` after an `ELSE` block"); // LCOV_EXCL_LINE
}
if (!toEndc && lexer_GetIFDepth() == startingDepth) {
return token;
@@ -2182,7 +2182,7 @@ static Token skipIfBlock(bool toEndc) {
case T_(POP_ELSE):
if (lexer_ReachedELSEBlock()) {
fatal("Found ELSE after an ELSE block");
fatal("Found `ELSE` after an `ELSE` block");
}
lexer_ReachELSEBlock();
if (!toEndc && lexer_GetIFDepth() == startingDepth) {
@@ -2260,7 +2260,7 @@ yy::parser::symbol_type yylex() {
lexerState->atLineStart = token.type == T_(NEWLINE) || token.type == T_(EOB);
// LCOV_EXCL_START
verbosePrint(VERB_TRACE, "Lexed '%s' token\n", yy::parser::symbol_type(token.type).name());
verbosePrint(VERB_TRACE, "Lexed `%s` token\n", yy::parser::symbol_type(token.type).name());
// LCOV_EXCL_STOP
if (std::holds_alternative<uint32_t>(token.value)) {
@@ -2345,7 +2345,7 @@ Capture lexer_CaptureRept() {
// Just consume characters until EOL or EOF
if (int c = skipChars([](int d) { return d != EOF && !isNewline(d); }); c == EOF) {
error("Unterminated REPT/FOR block");
error("Unterminated loop (`REPT`/`FOR` block)");
endCapture(capture);
capture.span.ptr = nullptr; // Indicates that it reached EOF before an ENDR
return capture;

View File

@@ -87,7 +87,7 @@ static Usage usage = {
{{"-E", "--export-all"}, {"export all labels"}},
{{"-M", "--dependfile <path>"}, {"set the output dependency file"}},
{{"-o", "--output <path>"}, {"set the output object file"}},
{{"-p", "--pad-value <value>"}, {"set the value to use for `ds'"}},
{{"-p", "--pad-value <value>"}, {"set the value to use for `DS`"}},
{{"-s", "--state <features>:<path>"}, {"set an output state file"}},
{{"-V", "--version"}, {"print RGBASM version and exit"}},
{{"-W", "--warning <warning>"}, {"enable or disable warnings"}},
@@ -257,7 +257,7 @@ static std::vector<StateFeature> parseStateFeatures(char *str) {
}
// A feature must be specified
if (*feature == '\0') {
fatal("Empty feature for option 's'");
fatal("Empty feature for option '-s'");
}
// Parse the `feature` and update the `features` list
static UpperMap<StateFeature> const featureNames{
@@ -269,14 +269,14 @@ static std::vector<StateFeature> parseStateFeatures(char *str) {
};
if (!strcasecmp(feature, "all")) {
if (!features.empty()) {
warnx("Redundant feature before \"%s\" for option 's'", feature);
warnx("Redundant feature before \"%s\" for option '-s'", feature);
}
features.assign({STATE_EQU, STATE_VAR, STATE_EQUS, STATE_CHAR, STATE_MACRO});
} else if (auto search = featureNames.find(feature); search == featureNames.end()) {
fatal("Invalid feature for option 's': \"%s\"", feature);
fatal("Invalid feature for option '-s': \"%s\"", feature);
} else if (StateFeature value = search->second;
std::find(RANGE(features), value) != features.end()) {
warnx("Ignoring duplicate feature for option 's': \"%s\"", feature);
warnx("Ignoring duplicate feature for option '-s': \"%s\"", feature);
} else {
features.push_back(value);
}
@@ -312,11 +312,11 @@ int main(int argc, char *argv[]) {
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;
}
@@ -325,7 +325,7 @@ int main(int argc, char *argv[]) {
if (strlen(musl_optarg) == 2) {
opt_B(musl_optarg);
} else {
fatal("Must specify exactly 2 characters for option 'b'");
fatal("Must specify exactly 2 characters for option '-b'");
}
break;
@@ -348,7 +348,7 @@ int main(int argc, char *argv[]) {
if (strlen(musl_optarg) == 4) {
opt_G(musl_optarg);
} else {
fatal("Must specify exactly 4 characters for option 'g'");
fatal("Must specify exactly 4 characters for option '-g'");
}
break;
@@ -362,7 +362,7 @@ int main(int argc, char *argv[]) {
case 'M':
if (dependFileName) {
warnx(
"Overriding dependency file %s",
"Overriding dependency file \"%s\"",
strcmp(dependFileName, "-") ? dependFileName : "<stdout>"
);
}
@@ -371,7 +371,7 @@ int main(int argc, char *argv[]) {
case 'o':
if (!options.objectFileName.empty()) {
warnx("Overriding output filename %s", options.objectFileName.c_str());
warnx("Overriding output file \"%s\"", options.objectFileName.c_str());
}
options.objectFileName = musl_optarg;
break;
@@ -385,11 +385,11 @@ int main(int argc, char *argv[]) {
padByte = 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 (padByte > 0xFF) {
fatal("Argument for option 'p' must be between 0 and 0xFF");
fatal("Argument for option '-p' must be between 0 and 0xFF");
}
opt_P(padByte);
@@ -403,11 +403,11 @@ int main(int argc, char *argv[]) {
unsigned long precision = strtoul(precisionArg, &endptr, 0);
if (musl_optarg[0] == '\0' || *endptr != '\0') {
fatal("Invalid argument for option 'Q'");
fatal("Invalid argument for option '-Q'");
}
if (precision < 1 || precision > 31) {
fatal("Argument for option 'Q' must be between 1 and 31");
fatal("Argument for option '-Q' must be between 1 and 31");
}
opt_Q(precision);
@@ -418,7 +418,7 @@ int main(int argc, char *argv[]) {
options.maxRecursionDepth = strtoul(musl_optarg, &endptr, 0);
if (musl_optarg[0] == '\0' || *endptr != '\0') {
fatal("Invalid argument for option 'r'");
fatal("Invalid argument for option '-r'");
}
break;
@@ -426,14 +426,14 @@ int main(int argc, char *argv[]) {
// Split "<features>:<name>" so `musl_optarg` is "<features>" and `name` is "<name>"
char *name = strchr(musl_optarg, ':');
if (!name) {
fatal("Invalid argument for option 's'");
fatal("Invalid argument for option '-s'");
}
*name++ = '\0';
std::vector<StateFeature> features = parseStateFeatures(musl_optarg);
if (stateFileSpecs.find(name) != stateFileSpecs.end()) {
warnx("Overriding state filename %s", name);
warnx("Overriding state file \"%s\"", name);
}
stateFileSpecs.emplace(name, std::move(features));
break;
@@ -461,11 +461,11 @@ int main(int argc, char *argv[]) {
uint64_t maxErrors = strtoul(musl_optarg, &endptr, 0);
if (musl_optarg[0] == '\0' || *endptr != '\0') {
fatal("Invalid argument for option 'X'");
fatal("Invalid argument for option '-X'");
}
if (maxErrors > UINT64_MAX) {
fatal("Argument for option 'X' must be between 0 and %" PRIu64, UINT64_MAX);
fatal("Argument for option '-X' must be between 0 and %" PRIu64, UINT64_MAX);
}
options.maxErrors = maxErrors;
@@ -525,14 +525,14 @@ int main(int argc, char *argv[]) {
verboseOutputConfig(argc, argv);
if (argc == musl_optind) {
usage.printAndExit("No input file specified (pass `-` to read from standard input)");
usage.printAndExit("No input file specified (pass \"-\" to read from standard input)");
} else if (argc != musl_optind + 1) {
usage.printAndExit("More than one input file specified");
}
std::string mainFileName = argv[musl_optind];
verbosePrint(VERB_NOTICE, "Assembling %s\n", mainFileName.c_str()); // LCOV_EXCL_LINE
verbosePrint(VERB_NOTICE, "Assembling \"%s\"\n", mainFileName.c_str()); // LCOV_EXCL_LINE
if (dependFileName) {
if (strcmp("-", dependFileName)) {
@@ -549,7 +549,7 @@ int main(int argc, char *argv[]) {
if (options.dependFile && options.targetFileName.empty()) {
fatal("Dependency files can only be created if a target file is specified with either "
"-o, -MQ or -MT");
"'-o', '-MQ' or '-MT'");
}
options.printDep(mainFileName);

View File

@@ -121,7 +121,7 @@ void opt_Parse(char const *s) {
}
if (s[0] == '\0') {
error("Missing argument to option 'r'");
error("Missing argument for option 'r'");
break;
}
@@ -129,9 +129,9 @@ void opt_Parse(char const *s) {
unsigned long maxRecursionDepth = strtoul(s, &endptr, 10);
if (*endptr != '\0') {
error("Invalid argument to option 'r' (\"%s\")", s);
error("Invalid argument for option 'r' (\"%s\")", s);
} else if (errno == ERANGE) {
error("Argument to 'r' is out of range (\"%s\")", s);
error("Argument for option 'r' is out of range (\"%s\")", s);
} else {
opt_R(maxRecursionDepth);
}

View File

@@ -303,7 +303,7 @@ void out_WriteObject() {
if (!file) {
// LCOV_EXCL_START
fatal(
"Failed to open object file '%s': %s", options.objectFileName.c_str(), strerror(errno)
"Failed to open object file \"%s\": %s", options.objectFileName.c_str(), strerror(errno)
);
// LCOV_EXCL_STOP
}
@@ -485,7 +485,7 @@ void out_WriteState(std::string name, std::vector<StateFeature> const &features)
}
if (!file) {
// LCOV_EXCL_START
fatal("Failed to open state file '%s': %s", name.c_str(), strerror(errno));
fatal("Failed to open state file \"%s\": %s", name.c_str(), strerror(errno));
// LCOV_EXCL_STOP
}
Defer closeFile{[&] { fclose(file); }};

View File

@@ -423,12 +423,14 @@ diff_mark:
%empty // OK
| OP_ADD {
::error(
"syntax error, unexpected + at the beginning of the line (is it a leftover diff mark?)"
"syntax error, unexpected '+' at the beginning of the line (is it a leftover diff "
"mark?)"
);
}
| OP_SUB {
::error(
"syntax error, unexpected - at the beginning of the line (is it a leftover diff mark?)"
"syntax error, unexpected '-' at the beginning of the line (is it a leftover diff "
"mark?)"
);
}
;
@@ -1594,7 +1596,7 @@ string:
if (Symbol *sym = sym_FindScopedSymbol($1); sym && sym->type == SYM_EQUS) {
$$ = *sym->getEqus();
} else {
::error("'%s' is not a string symbol", $1.c_str());
::error("`%s` is not a string symbol", $1.c_str());
}
}
;
@@ -2041,7 +2043,7 @@ ff00_c_ind:
LBRACK relocexpr OP_ADD MODE_C RBRACK {
// This has to use `relocexpr`, not `iconst`, to avoid a shift/reduce conflict
if ($2.getConstVal() != 0xFF00) {
::error("Base value must be equal to $FF00 for $FF00+C");
::error("Base value must be equal to $FF00 for [$FF00+C]");
}
}
;
@@ -2068,7 +2070,7 @@ sm83_ld_hl:
}
| SM83_LD MODE_HL COMMA reg_tt_no_af {
::error(
"LD HL, %s is not a valid instruction; use LD H, %s and LD L, %s",
"\"LD HL, %s\" is not a valid instruction; use \"LD H, %s\" and \"LD L, %s\"",
reg_tt_names[$4],
reg_tt_high_names[$4],
reg_tt_low_names[$4]
@@ -2081,7 +2083,7 @@ sm83_ld_sp:
sect_ConstByte(0xF9);
}
| SM83_LD MODE_SP COMMA reg_bc_or_de {
::error("LD SP, %s is not a valid instruction", reg_tt_names[$4]);
::error("\"LD SP, %s\" is not a valid instruction", reg_tt_names[$4]);
}
| SM83_LD MODE_SP COMMA reloc_16bit {
sect_ConstByte(0x01 | (REG_SP << 4));
@@ -2119,7 +2121,7 @@ sm83_ld_r_no_a:
}
| SM83_LD reg_r_no_a COMMA reg_r {
if ($2 == REG_HL_IND && $4 == REG_HL_IND) {
::error("LD [HL], [HL] is not a valid instruction");
::error("\"LD [HL], [HL]\" is not a valid instruction");
} else {
sect_ConstByte(0x40 | ($2 << 3) | $4);
}
@@ -2153,7 +2155,7 @@ sm83_ld_ss:
}
| SM83_LD reg_bc_or_de COMMA reg_tt_no_af {
::error(
"LD %s, %s is not a valid instruction; use LD %s, %s and LD %s, %s",
"\"LD %s, %s\" is not a valid instruction; use \"LD %s, %s\" and \"LD %s, %s\"",
reg_tt_names[$2],
reg_tt_names[$4],
reg_tt_high_names[$2],
@@ -2407,7 +2409,7 @@ op_sp_offset:
$$.checkNBit(8);
}
| %empty {
::error("LD HL, SP is not a valid instruction; use LD HL, SP + 0");
::error("\"LD HL, SP\" is not a valid instruction; use \"LD HL, SP + 0\"");
}
;

View File

@@ -77,15 +77,15 @@ void Expression::makeSymbol(std::string const &symName) {
error("PC has no value outside of a section");
data = 0;
} else if (sym && !sym->isNumeric() && !sym->isLabel()) {
error("'%s' is not a numeric symbol", symName.c_str());
error("`%s` is not a numeric symbol", symName.c_str());
data = 0;
} else if (!sym || !sym->isConstant()) {
isSymbol = true;
data = sym_IsPC(sym) ? "PC is not constant at assembly time"
: sym_IsPurgedScoped(symName)
? "'"s + symName + "' is not constant at assembly time; it was purged"
: "'"s + symName + "' is not constant at assembly time";
? "`"s + symName + "` is not constant at assembly time; it was purged"
: "`"s + symName + "` is not constant at assembly time";
sym = sym_Ref(symName);
size_t nameLen = sym->name.length() + 1; // Don't forget NUL!
@@ -115,7 +115,7 @@ void Expression::makeBankSymbol(std::string const &symName) {
}
return;
} else if (sym && !sym->isLabel()) {
error("BANK argument must be a label");
error("`BANK` argument must be a label");
data = 1;
} else {
sym = sym_Ref(symName);
@@ -126,8 +126,8 @@ void Expression::makeBankSymbol(std::string const &symName) {
data = static_cast<int32_t>(sym->getSection()->bank);
} else {
data = sym_IsPurgedScoped(symName)
? "\""s + symName + "\"'s bank is not known; it was purged"
: "\""s + symName + "\"'s bank is not known";
? "`"s + symName + "`'s bank is not known; it was purged"
: "`"s + symName + "`'s bank is not known";
size_t nameLen = sym->name.length() + 1; // Room for NUL!
@@ -539,7 +539,7 @@ void Expression::makeCheckRST() {
*reserveSpace(1) = RPN_RST;
} else if (int32_t val = value(); val & ~0x38) {
// A valid RST address must be masked with 0x38
error("Invalid address $%" PRIx32 " for RST", val);
error("Invalid address $%" PRIx32 " for `RST`", val);
}
}
@@ -552,7 +552,7 @@ void Expression::makeCheckBitIndex(uint8_t mask) {
*ptr = mask;
} else if (int32_t val = value(); val & ~0x07) {
// A valid bit index must be masked with 0x07
static char const *instructions[4] = {"instruction", "BIT", "RES", "SET"};
static char const *instructions[4] = {"instruction", "`BIT`", "`RES`", "`SET`"};
error("Invalid bit index %" PRId32 " for %s", val, instructions[mask >> 6]);
}
}
@@ -574,7 +574,7 @@ bool checkNBit(int32_t v, uint8_t n, char const *name) {
"%s must be %u-bit%s",
name ? name : "Expression",
n,
n == 8 && !name ? "; use LOW() to force 8-bit" : ""
n == 8 && !name ? "; use `LOW()` to force 8-bit" : ""
);
return false;
}
@@ -584,7 +584,7 @@ bool checkNBit(int32_t v, uint8_t n, char const *name) {
"%s must be %u-bit%s",
name ? name : "Expression",
n,
n == 8 && !name ? "; use LOW() to force 8-bit" : ""
n == 8 && !name ? "; use `LOW()` to force 8-bit" : ""
);
return false;
}

View File

@@ -57,7 +57,7 @@ static bool requireSection() {
return true;
}
error("Cannot output data outside of a SECTION");
error("Cannot output data outside of a `SECTION`");
return false;
}
@@ -72,7 +72,8 @@ static bool requireCodeSection() {
}
error(
"Section '%s' cannot contain code or data (not ROM0 or ROMX)", currentSection->name.c_str()
"Section \"%s\" cannot contain code or data (not `ROM0` or `ROMX`)",
currentSection->name.c_str()
);
return false;
}
@@ -91,7 +92,8 @@ void sect_CheckSizes() {
for (Section const &sect : sectionList) {
if (uint32_t maxSize = sectionTypeInfo[sect.type].size; sect.size > maxSize) {
error(
"Section '%s' grew too big (max size = 0x%" PRIX32 " bytes, reached 0x%" PRIX32 ")",
"Section \"%s\" grew too big (max size = 0x%" PRIX32 " bytes, reached 0x%" PRIX32
")",
sect.name.c_str(),
maxSize,
sect.size
@@ -127,7 +129,7 @@ static unsigned int mergeSectUnion(
// Unionized sections only need "compatible" constraints, and they end up with the strictest
// combination of both.
if (sect_HasData(type)) {
sectError("Cannot declare ROM sections as UNION");
sectError("Cannot declare ROM sections as `UNION`");
}
if (org != UINT32_MAX) {
@@ -254,12 +256,12 @@ static void mergeSections(
if (type != sect.type) {
sectError(
"Section already exists but with type %s", sectionTypeInfo[sect.type].name.c_str()
"Section already exists but with type `%s`", sectionTypeInfo[sect.type].name.c_str()
);
}
if (sect.modifier != mod) {
sectError("Section already declared as SECTION %s", sectionModNames[sect.modifier]);
sectError("Section already declared as `SECTION %s`", sectionModNames[sect.modifier]);
} else {
switch (mod) {
case SECTION_UNION:
@@ -383,7 +385,7 @@ static Section *getSection(
if (bank != UINT32_MAX) {
if (type != SECTTYPE_ROMX && type != SECTTYPE_VRAM && type != SECTTYPE_SRAM
&& type != SECTTYPE_WRAMX) {
error("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
error("`BANK` only allowed for `ROMX`, `WRAMX`, `SRAM`, or `VRAM` sections");
} else if (bank < sectionTypeInfo[type].firstBank
|| bank > sectionTypeInfo[type].lastBank) {
error(
@@ -425,7 +427,7 @@ static Section *getSection(
// It doesn't make sense to have both alignment and org set
if (org != UINT32_MAX) {
if ((org - alignOffset) & alignMask) {
error("Section \"%s\"'s fixed address doesn't match its alignment", name.c_str());
error("Section \"%s\"'s fixed address does not match its alignment", name.c_str());
}
alignment = 0; // Ignore it if it's satisfied
} else if (sectionTypeInfo[type].startAddr & alignMask) {
@@ -459,7 +461,7 @@ static Section *getSection(
static void changeSection() {
if (!currentUnionStack.empty()) {
fatal("Cannot change the section within a UNION");
fatal("Cannot change the section within a `UNION`");
}
sym_ResetCurrentLabelScopes();
@@ -505,7 +507,7 @@ void sect_NewSection(
) {
for (SectionStackEntry &entry : sectionStack) {
if (entry.section && entry.section->name == name) {
fatal("Section '%s' is already on the stack", name.c_str());
fatal("Section \"%s\" is already on the stack", name.c_str());
}
}
@@ -710,11 +712,11 @@ void sect_StartUnion() {
// your own peril! ^^
if (!currentSection) {
error("UNIONs must be inside a SECTION");
error("`UNION`s must be inside a `SECTION`");
return;
}
if (sect_HasData(currentSection->type)) {
error("Cannot use UNION inside of ROM0 or ROMX sections");
error("Cannot use `UNION` inside of `ROM0` or `ROMX` sections");
return;
}
@@ -733,7 +735,7 @@ static void endUnionMember() {
void sect_NextUnionMember() {
if (currentUnionStack.empty()) {
error("Found NEXTU outside of a UNION construct");
error("Found `NEXTU` outside of a `UNION` construct");
return;
}
endUnionMember();
@@ -741,7 +743,7 @@ void sect_NextUnionMember() {
void sect_EndUnion() {
if (currentUnionStack.empty()) {
error("Found ENDU outside of a UNION construct");
error("Found `ENDU` outside of a `UNION` construct");
return;
}
endUnionMember();
@@ -751,7 +753,7 @@ void sect_EndUnion() {
void sect_CheckUnionClosed() {
if (!currentUnionStack.empty()) {
error("Unterminated UNION construct");
error("Unterminated `UNION` construct");
}
}
@@ -816,7 +818,7 @@ void sect_Skip(uint32_t skip, bool ds) {
if (!ds) {
warning(
WARNING_EMPTY_DATA_DIRECTIVE,
"%s directive without data in ROM",
"`%s` directive without data in ROM",
(skip == 4) ? "DL"
: (skip == 2) ? "DW"
: "DB"
@@ -905,8 +907,8 @@ void sect_PCRelByte(Expression const &expr, uint32_t pcShift) {
if (offset < -128 || offset > 127) {
error(
"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",
offset
);
writeByte(0);
@@ -932,19 +934,23 @@ bool sect_BinaryFile(std::string const &name, uint32_t startPos) {
if (fseek(file, 0, SEEK_END) == 0) {
if (startPos > ftell(file)) {
error("Specified start position is greater than length of file '%s'", name.c_str());
error("Specified start position is greater than length of file \"%s\"", name.c_str());
return false;
}
// The file is seekable; skip to the specified start position
fseek(file, startPos, SEEK_SET);
} else {
if (errno != ESPIPE) {
error("Error determining size of INCBIN file '%s': %s", name.c_str(), strerror(errno));
error(
"Error determining size of `INCBIN` file \"%s\": %s", name.c_str(), strerror(errno)
);
}
// The file isn't seekable, so we'll just skip bytes one at a time
while (startPos--) {
if (fgetc(file) == EOF) {
error("Specified start position is greater than length of file '%s'", name.c_str());
error(
"Specified start position is greater than length of file \"%s\"", name.c_str()
);
return false;
}
}
@@ -955,7 +961,7 @@ bool sect_BinaryFile(std::string const &name, uint32_t startPos) {
}
if (ferror(file)) {
error("Error reading INCBIN file '%s': %s", name.c_str(), strerror(errno));
error("Error reading `INCBIN` file \"%s\": %s", name.c_str(), strerror(errno));
}
return false;
}
@@ -979,11 +985,11 @@ bool sect_BinaryFileSlice(std::string const &name, uint32_t startPos, uint32_t l
if (fseek(file, 0, SEEK_END) == 0) {
if (long fsize = ftell(file); startPos > fsize) {
error("Specified start position is greater than length of file '%s'", name.c_str());
error("Specified start position is greater than length of file \"%s\"", name.c_str());
return false;
} else if (startPos + length > fsize) {
error(
"Specified range in INCBIN file '%s' is out of bounds (%" PRIu32 " + %" PRIu32
"Specified range in `INCBIN` file \"%s\" is out of bounds (%" PRIu32 " + %" PRIu32
" > %ld)",
name.c_str(),
startPos,
@@ -996,12 +1002,16 @@ bool sect_BinaryFileSlice(std::string const &name, uint32_t startPos, uint32_t l
fseek(file, startPos, SEEK_SET);
} else {
if (errno != ESPIPE) {
error("Error determining size of INCBIN file '%s': %s", name.c_str(), strerror(errno));
error(
"Error determining size of `INCBIN` file \"%s\": %s", name.c_str(), strerror(errno)
);
}
// The file isn't seekable, so we'll just skip bytes one at a time
while (startPos--) {
if (fgetc(file) == EOF) {
error("Specified start position is greater than length of file '%s'", name.c_str());
error(
"Specified start position is greater than length of file \"%s\"", name.c_str()
);
return false;
}
}
@@ -1011,10 +1021,10 @@ bool sect_BinaryFileSlice(std::string const &name, uint32_t startPos, uint32_t l
if (int byte = fgetc(file); byte != EOF) {
writeByte(byte);
} else if (ferror(file)) {
error("Error reading INCBIN file '%s': %s", name.c_str(), strerror(errno));
error("Error reading `INCBIN` file \"%s\": %s", name.c_str(), strerror(errno));
} else {
error(
"Premature end of INCBIN file '%s' (%" PRId32 " bytes left to read)",
"Premature end of `INCBIN` file \"%s\" (%" PRId32 " bytes left to read)",
name.c_str(),
length + 1
);
@@ -1069,11 +1079,11 @@ void sect_CheckStack() {
void sect_EndSection() {
if (!currentSection) {
fatal("Cannot end the section outside of a SECTION");
fatal("Cannot end the section outside of a `SECTION`");
}
if (!currentUnionStack.empty()) {
fatal("Cannot end the section within a UNION");
fatal("Cannot end the section within a `UNION`");
}
if (currentLoadSection) {
@@ -1090,11 +1100,11 @@ std::string sect_PushSectionFragmentLiteral() {
// Like `requireCodeSection` but fatal
if (!currentSection) {
fatal("Cannot output fragment literals outside of a SECTION");
fatal("Cannot output fragment literals outside of a `SECTION`");
}
if (!sect_HasData(currentSection->type)) {
fatal(
"Section '%s' cannot contain fragment literals (not ROM0 or ROMX)",
"Section \"%s\" cannot contain fragment literals (not `ROM0` or `ROMX`)",
currentSection->name.c_str()
);
}

View File

@@ -54,14 +54,14 @@ static int32_t NARGCallback() {
if (MacroArgs const *macroArgs = fstk_GetCurrentMacroArgs(); macroArgs) {
return macroArgs->nbArgs();
} else {
error("_NARG has no value outside of a macro");
error("`_NARG` has no value outside of a macro");
return 0;
}
}
static std::shared_ptr<std::string> globalScopeCallback() {
if (!globalScope) {
error("\".\" has no value outside of a label scope");
error("`.` has no value outside of a label scope");
return std::make_shared<std::string>("");
}
return std::make_shared<std::string>(globalScope->name);
@@ -69,7 +69,7 @@ static std::shared_ptr<std::string> globalScopeCallback() {
static std::shared_ptr<std::string> localScopeCallback() {
if (!localScope) {
error("\"..\" has no value outside of a local label scope");
error("`..` has no value outside of a local label scope");
return std::make_shared<std::string>("");
}
return std::make_shared<std::string>(localScope->name);
@@ -156,22 +156,22 @@ static void alreadyDefinedError(Symbol const &sym, char const *asType) {
if (sym.isBuiltin) {
if (sym_FindScopedValidSymbol(sym.name)) {
if (std::string s = suggestion(); asType) {
error("'%s' already defined as built-in %s%s", sym.name.c_str(), asType, s.c_str());
error("`%s` already defined as built-in %s%s", sym.name.c_str(), asType, s.c_str());
} else {
error("'%s' already defined as built-in%s", sym.name.c_str(), s.c_str());
error("`%s` already defined as built-in%s", sym.name.c_str(), s.c_str());
}
} else {
// `DEF()` would return false, so we should not claim the symbol is already defined,
// nor suggest to interpolate it
if (asType) {
error("'%s' is reserved for a built-in %s symbol", sym.name.c_str(), asType);
error("`%s` is reserved for a built-in %s symbol", sym.name.c_str(), asType);
} else {
error("'%s' is reserved for a built-in symbol", sym.name.c_str());
error("`%s` is reserved for a built-in symbol", sym.name.c_str());
}
}
} else {
errorNoTrace([&]() {
fprintf(stderr, "'%s' already defined", sym.name.c_str());
fprintf(stderr, "`%s` already defined", sym.name.c_str());
if (asType) {
fprintf(stderr, " as %s", asType);
}
@@ -184,10 +184,10 @@ static void alreadyDefinedError(Symbol const &sym, char const *asType) {
static void redefinedError(Symbol const &sym) {
assume(sym.isBuiltin);
if (sym_FindScopedValidSymbol(sym.name)) {
error("Built-in symbol '%s' cannot be redefined", sym.name.c_str());
error("Built-in symbol `%s` cannot be redefined", sym.name.c_str());
} else {
// `DEF()` would return false, so we should not imply the symbol is already defined
error("'%s' is reserved for a built-in symbol", sym.name.c_str());
error("`%s` is reserved for a built-in symbol", sym.name.c_str());
}
}
@@ -236,12 +236,12 @@ static bool isAutoScoped(std::string const &symName) {
// Check for nothing after the dot
if (dotPos == symName.length() - 1) {
fatal("'%s' is a nonsensical reference to an empty local label", symName.c_str());
fatal("`%s` is a nonsensical reference to an empty local label", symName.c_str());
}
// Check for more than one dot
if (symName.find('.', dotPos + 1) != std::string::npos) {
fatal("'%s' is a nonsensical reference to a nested local label", symName.c_str());
fatal("`%s` is a nonsensical reference to a nested local label", symName.c_str());
}
// Check for already-qualified local label
@@ -251,7 +251,7 @@ static bool isAutoScoped(std::string const &symName) {
// Check for unqualifiable local label
if (!globalScope) {
fatal("Unqualified local label '%s' in main scope", symName.c_str());
fatal("Unqualified local label `%s` in main scope", symName.c_str());
}
return true;
@@ -300,19 +300,19 @@ void sym_Purge(std::string const &symName) {
if (!sym) {
if (sym_IsPurgedScoped(symName)) {
error("Undefined symbol '%s' was already purged", symName.c_str());
error("Undefined symbol `%s` was already purged", symName.c_str());
} else {
error("Undefined symbol '%s'", 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());
error("Built-in symbol `%s` cannot be purged", symName.c_str());
} else if (sym->ID != UINT32_MAX) {
error("Symbol \"%s\" is referenced and thus cannot be purged", symName.c_str());
error("Symbol `%s` is referenced and thus cannot be purged", symName.c_str());
} else {
if (sym->isExported) {
warning(WARNING_PURGE_1, "Purging an exported symbol \"%s\"", symName.c_str());
warning(WARNING_PURGE_1, "Purging an exported symbol `%s`", symName.c_str());
} else if (sym->isLabel()) {
warning(WARNING_PURGE_2, "Purging a label \"%s\"", symName.c_str());
warning(WARNING_PURGE_2, "Purging a label `%s`", symName.c_str());
}
// Do not keep a reference to the label after purging it
if (sym == globalScope) {
@@ -357,7 +357,7 @@ uint32_t Symbol::getConstantValue() const {
error("PC does not have a constant value; the current section is not fixed");
}
} else {
error("\"%s\" does not have a constant value", name.c_str());
error("`%s` does not have a constant value", name.c_str());
}
return 0;
}
@@ -393,7 +393,7 @@ static Symbol *createNonrelocSymbol(std::string const &symName, bool numeric) {
} else if (!numeric) {
// The symbol has already been referenced, but it's not allowed
errorNoTrace([&]() {
fprintf(stderr, "'%s' already referenced", symName.c_str());
fprintf(stderr, "`%s` already referenced", symName.c_str());
printBacktraces(*sym);
});
return nullptr; // Don't allow overriding the symbol, that'd be bad!
@@ -423,7 +423,7 @@ Symbol *sym_RedefEqu(std::string const &symName, int32_t value) {
}
if (sym->isDefined() && sym->type != SYM_EQU) {
alreadyDefinedError(*sym, "non-EQU");
alreadyDefinedError(*sym, "non-`EQU`");
return nullptr;
} else if (sym->isBuiltin) {
redefinedError(*sym);
@@ -458,10 +458,10 @@ Symbol *sym_RedefString(std::string const &symName, std::shared_ptr<std::string>
if (sym->type != SYM_EQUS) {
if (sym->isDefined()) {
alreadyDefinedError(*sym, "non-EQUS");
alreadyDefinedError(*sym, "non-`EQUS`");
} else {
errorNoTrace([&]() {
fprintf(stderr, "'%s' already referenced", symName.c_str());
fprintf(stderr, "`%s` already referenced", symName.c_str());
printBacktraces(*sym);
});
}
@@ -518,7 +518,7 @@ static Symbol *addLabel(std::string const &symName) {
sym->section = sect_GetSymbolSection();
if (sym && !sym->section) {
error("Label \"%s\" created outside of a SECTION", symName.c_str());
error("Label `%s` created outside of a `SECTION`", symName.c_str());
}
return sym;
@@ -588,7 +588,7 @@ std::string sym_MakeAnonLabelName(uint32_t ofs, bool neg) {
// LCOV_EXCL_START
error(
"Reference to anonymous label %" PRIu32 " after, when only %" PRIu32
" may still be created",
" can still be created",
ofs + 1,
UINT32_MAX - anonLabelID
);

View File

@@ -75,15 +75,15 @@ static Usage usage = {
{
{"-m", "--mbc-type <value>"},
{
"set the MBC type byte to this value; `-m help'",
"or `-m list' prints the accepted values",
"set the MBC type byte to this value; \"-m help\"",
"or \"-m list\" prints the accepted values",
},
},
{{"-p", "--pad-value <value>"}, {"pad to the next valid size using this value"}},
{{"-r", "--ram-size <code>"}, {"set the cart RAM size byte to this value"}},
{{"-o", "--output <path>"}, {"set the output file"}},
{{"-V", "--version"}, {"print RGBFIX version and exit"}},
{{"-v", "--validate"}, {"fix the header logo and both checksums (`-f lhg')"}},
{{"-v", "--validate"}, {"fix the header logo and both checksums (\"-f lhg\")"}},
{{"-W", "--warning <warning>"}, {"enable or disable warnings"}},
},
};
@@ -353,7 +353,7 @@ static void
// Update bank count, ONLY IF at least one byte was read
if (bankLen) {
// We're gonna read another bank, check that it won't be too much
// We're going to read another bank, check that it won't be too much
static_assert(
0x10000 * BANK_SIZE <= SSIZE_MAX, "Max input file size too large for OS"
);
@@ -613,7 +613,7 @@ static bool processFilename(char const *name, char const *outputName) {
static void parseByte(uint16_t &output, char name) {
if (musl_optarg[0] == 0) {
fatal("Argument to option '%c' may not be empty", name);
fatal("Argument to option '-%c' may not be empty", name);
}
char *endptr;
@@ -625,9 +625,9 @@ static void parseByte(uint16_t &output, char name) {
}
if (*endptr) {
fatal("Expected number as argument to option '%c', got %s", name, musl_optarg);
fatal("Expected number as argument to option '-%c', got \"%s\"", name, musl_optarg);
} else if (value > 0xFF) {
fatal("Argument to option '%c' is larger than 255: %lu", name, value);
fatal("Argument to option '-%c' is larger than 255: %lu", name, value);
}
output = value;
@@ -849,7 +849,7 @@ int main(int argc, char *argv[]) {
if ((cartridgeType & 0xFF00) == TPP1 && !japanese) {
warning(
WARNING_MBC, "TPP1 overwrites region flag for its identification code, ignoring `-j`"
WARNING_MBC, "TPP1 overwrites region flag for its identification code, ignoring '-j'"
);
}
@@ -859,7 +859,7 @@ int main(int argc, char *argv[]) {
if (ramSize != 1) {
warning(
WARNING_MBC,
"MBC \"%s\" should have 2 KiB of RAM (-r 1)",
"MBC \"%s\" should have 2 KiB of RAM (\"-r 1\")",
mbc_Name(cartridgeType)
);
}
@@ -899,11 +899,11 @@ int main(int argc, char *argv[]) {
argv += musl_optind;
if (!*argv) {
usage.printAndExit("No input file specified (pass `-` to read from standard input)");
usage.printAndExit("No input file specified (pass \"-\" to read from standard input)");
}
if (outputFilename && argc != musl_optind + 1) {
usage.printAndExit("If `-o` is set then only a single input file may be specified");
usage.printAndExit("If '-o' is set then only a single input file may be specified");
}
bool failed = warnings.nbErrors > 0;

View File

@@ -157,7 +157,7 @@ MbcType mbc_ParseName(char const *name, uint8_t &tpp1Major, uint8_t &tpp1Minor)
fatalUnknownMBC(fullName);
}
if (mbc > 0xFF) {
fatal("Specified MBC ID out of range 0-255: %s", fullName);
fatal("Specified MBC ID out of range 0-255: \"%s\"", fullName);
}
return static_cast<MbcType>(mbc);
}
@@ -415,7 +415,7 @@ MbcType mbc_ParseName(char const *name, uint8_t &tpp1Major, uint8_t &tpp1Minor)
// Handle timer, which also requires battery
if (features & TIMER) {
if (!(features & BATTERY)) {
warning(WARNING_MBC, "MBC3+TIMER implies BATTERY");
warning(WARNING_MBC, "\"MBC3+TIMER\" implies \"BATTERY\"");
}
features &= ~(TIMER | BATTERY); // Reset those bits
mbc = MBC3_TIMER_BATTERY;

View File

@@ -208,7 +208,7 @@ static void registerInput(char const *arg) {
static std::vector<size_t> readAtFile(std::string const &path, std::vector<char> &argPool) {
File file;
if (!file.open(path, std::ios_base::in)) {
fatal("Error reading @%s: %s", file.c_str(path), strerror(errno));
fatal("Error reading at-file \"%s\": %s", file.c_str(path), strerror(errno));
}
for (std::vector<size_t> argvOfs;;) {
@@ -267,7 +267,7 @@ static char *parseArgv(int argc, char *argv[]) {
case 'a':
localOptions.autoAttrmap = false;
if (!options.attrmap.empty()) {
warnx("Overriding attrmap file %s", options.attrmap.c_str());
warnx("Overriding attrmap file \"%s\"", options.attrmap.c_str());
}
options.attrmap = musl_optarg;
break;
@@ -336,7 +336,7 @@ static char *parseArgv(int argc, char *argv[]) {
case 'd':
options.bitDepth = parseNumber(arg, "Bit depth", 2);
if (*arg != '\0') {
error("Bit depth (-b) argument must be a valid number, not \"%s\"", musl_optarg);
error("Bit depth ('-b') argument must be a valid number, not \"%s\"", musl_optarg);
} else if (options.bitDepth != 1 && options.bitDepth != 2) {
error("Bit depth must be 1 or 2, not %" PRIu8, options.bitDepth);
options.bitDepth = 2;
@@ -346,7 +346,7 @@ static char *parseArgv(int argc, char *argv[]) {
usage.printAndExit(0); // LCOV_EXCL_LINE
case 'i':
if (!options.inputTileset.empty()) {
warnx("Overriding input tileset file %s", options.inputTileset.c_str());
warnx("Overriding input tileset file \"%s\"", options.inputTileset.c_str());
}
options.inputTileset = musl_optarg;
break;
@@ -441,12 +441,12 @@ static char *parseArgv(int argc, char *argv[]) {
case 'n':
number = parseNumber(arg, "Number of palettes", 256);
if (*arg != '\0') {
error("Number of palettes (-n) must be a valid number, not \"%s\"", musl_optarg);
error("Number of palettes ('-n') must be a valid number, not \"%s\"", musl_optarg);
}
if (number > 256) {
error("Number of palettes (-n) must not exceed 256!");
error("Number of palettes ('-n') must not exceed 256!");
} else if (number == 0) {
error("Number of palettes (-n) may not be 0!");
error("Number of palettes ('-n') may not be 0!");
} else {
options.nbPalettes = number;
}
@@ -484,18 +484,20 @@ static char *parseArgv(int argc, char *argv[]) {
localOptions.reverse = true;
options.reversedWidth = parseNumber(arg, "Reversed image stride");
if (*arg != '\0') {
error("Reversed image stride (-r) must be a valid number, not \"%s\"", musl_optarg);
error(
"Reversed image stride ('-r') must be a valid number, not \"%s\"", musl_optarg
);
}
break;
case 's':
options.nbColorsPerPal = parseNumber(arg, "Number of colors per palette", 4);
if (*arg != '\0') {
error("Palette size (-s) must be a valid number, not \"%s\"", musl_optarg);
error("Palette size ('-s') must be a valid number, not \"%s\"", musl_optarg);
}
if (options.nbColorsPerPal > 4) {
error("Palette size (-s) must not exceed 4!");
error("Palette size ('-s') must not exceed 4!");
} else if (options.nbColorsPerPal == 0) {
error("Palette size (-s) may not be 0!");
error("Palette size ('-s') may not be 0!");
}
break;
case 'T':
@@ -527,7 +529,7 @@ static char *parseArgv(int argc, char *argv[]) {
case 'x':
options.trim = parseNumber(arg, "Number of tiles to trim", 0);
if (*arg != '\0') {
error("Tile trim (-x) argument must be a valid number, not \"%s\"", musl_optarg);
error("Tile trim ('-x') argument must be a valid number, not \"%s\"", musl_optarg);
}
break;
case 'X':
@@ -846,7 +848,7 @@ int main(int argc, char *argv[]) {
&& !localOptions.reverse) {
processPalettes();
} else {
usage.printAndExit("No input file specified (pass `-` to read from standard input)");
usage.printAndExit("No input file specified (pass \"-\" to read from standard input)");
}
requireZeroErrors();

View File

@@ -70,13 +70,11 @@ void parseInlinePalSpec(char const * const rawArg) {
error("%s", msg); // `format_` and `-Wformat-security` would complain about `error(msg);`
fprintf(
stderr,
"In inline palette spec: %s\n"
" ",
rawArg
"In inline palette spec: \"%s\"\n%*c",
rawArg,
static_cast<int>(literal_strlen("In inline palette spec: \"") + ofs),
' '
);
for (size_t i = ofs; i; --i) {
putc(' ', stderr);
}
for (size_t i = len; i; --i) {
putc('^', stderr);
}
@@ -300,7 +298,7 @@ static void parsePSPFile(char const *filename, std::filebuf &file) {
size_t n = 0;
std::optional<uint16_t> nbColors = parseDec<uint16_t>(line, n);
if (!nbColors || n != line.length()) {
error("Invalid \"number of colors\" line in PSP file (%s)", line.c_str());
error("Invalid \"number of colors\" line in PSP file (\"%s\")", line.c_str());
return;
}
@@ -651,7 +649,7 @@ void parseExternalPalSpec(char const *arg) {
// Split both parts, error out if malformed
char const *ptr = strchr(arg, ':');
if (ptr == nullptr) {
error("External palette spec must have format `fmt:path` (missing colon)");
error("External palette spec must have format \"fmt:path\" (missing colon)");
return;
}
char const *path = ptr + 1;
@@ -721,7 +719,7 @@ void parseBackgroundPalSpec(char const *arg) {
}
if (arg[0] != '#') {
error("Background color specification must be `#rgb`, `#rrggbb`, or `transparent`");
error("Background color specification must be \"#rgb\", \"#rrggbb\", or \"transparent\"");
return;
}

View File

@@ -312,7 +312,7 @@ static void generatePalSpec(Image const &image) {
// Generate a palette spec from the first few colors in the embedded palette
std::vector<Rgba> const &embPal = image.png.palette;
if (embPal.empty()) {
fatal("`-c embedded` was given, but the PNG does not have an embedded palette!");
fatal("\"-c embedded\" was given, but the PNG does not have an embedded palette!");
}
// Ignore extraneous colors if they are unused
@@ -794,7 +794,7 @@ static UniqueTiles dedupTiles(
if (matchType != TileData::NOPE) {
error(
"The input tileset's tile #%hu was deduplicated; please check that your "
"deduplication flags (`-u`, `-m`) are consistent with what was used to "
"deduplication flags ('-u', '-m') are consistent with what was used to "
"generate the input tileset",
tileID
);
@@ -815,7 +815,7 @@ static UniqueTiles dedupTiles(
if (inputWithoutOutput && matchType == TileData::NOPE) {
error(
"Tile at (%" PRIu32 ", %" PRIu32
") is not within the input tileset, and `-o` was not given!",
") is not within the input tileset, and '-o' was not given!",
tile.x,
tile.y
);
@@ -1078,8 +1078,7 @@ continue_visiting_tiles:;
// I currently cannot figure out useful semantics for this combination of flags.
if (!options.inputTileset.empty()) {
fatal("Input tilesets are not supported without `-u`\nPlease consider explaining your "
"use case to RGBDS' developers!");
fatal("Input tilesets are not supported without '-u'");
}
if (!options.output.empty()) {

View File

@@ -122,7 +122,7 @@ void reverse() {
if (options.inputSlice.width != 0 && options.inputSlice.width != options.reversedWidth * 8) {
warnx(
"Specified input slice width (%" PRIu16
") doesn't match provided reversing width (%" PRIu16 " * 8)",
") does not match provided reversing width (%" PRIu16 " * 8)",
options.inputSlice.width,
options.reversedWidth
);
@@ -179,7 +179,7 @@ void reverse() {
if (options.trim == 0 && !tilemap) {
fatal(
"Total number of tiles (%zu) cannot be divided by image width (%zu tiles)\n"
"(To proceed anyway with this image width, try passing `-x %zu`)",
"(To proceed anyway with this image width, try passing \"-x %zu\")",
mapSize,
width,
width - mapSize % width
@@ -242,9 +242,9 @@ void reverse() {
}
if (options.palSpecType == Options::EXPLICIT && palettes != options.palSpec) {
warnx("Colors in the palette file do not match those specified with `-c`!");
warnx("Colors in the palette file do not match those specified with '-c'!");
// This spacing aligns "...versus with `-c`" above the column of `-c` palettes
fputs("Colors specified in the palette file: ...versus with `-c`:\n", stderr);
fputs("Colors specified in the palette file: ...versus with '-c':\n", stderr);
for (size_t i = 0; i < palettes.size() && i < options.palSpec.size(); ++i) {
if (i < palettes.size()) {
printPalette(palettes[i]);
@@ -275,7 +275,7 @@ void reverse() {
attrmap = readInto(options.attrmap);
if (attrmap->size() != mapSize) {
fatal(
"Attribute map size (%zu tiles) doesn't match image's (%zu)",
"Attribute map size (%zu tiles) does not match image size (%zu tiles)",
attrmap->size(),
mapSize
);
@@ -396,7 +396,7 @@ void reverse() {
palmap = readInto(options.palmap);
if (palmap->size() != mapSize) {
fatal(
"Palette map size (%zu tiles) doesn't match image size (%zu)",
"Palette map size (%zu tiles) does not match image size (%zu tiles)",
palmap->size(),
mapSize
);

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()

View File

@@ -89,11 +89,11 @@ void Usage::printAndExit(int code) const {
// Print the link for further help information
style_Reset(file);
fputs("\nFor more help, use `", file);
fputs("\nFor more help, use \"", file);
style_Set(file, STYLE_CYAN, true);
fprintf(file, "man %s", name.c_str());
style_Reset(file);
fputs("' or go to ", file);
fputs("\" or go to ", file);
style_Set(file, STYLE_BLUE, true);
fputs("https://rgbds.gbdev.io/docs/", file);
style_Reset(file);