mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-29 14:27:50 +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:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user