mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 20:12:07 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 ¯oName, 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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); }};
|
||||
|
||||
@@ -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\"");
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 § : 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()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user