Accept both colons and semicolons in inline pal spec

This commit is contained in:
ISSOtm
2022-04-12 23:47:32 +02:00
committed by Eldred Habert
parent 32242e0ff2
commit 913c3dd711
2 changed files with 8 additions and 8 deletions

View File

@@ -122,12 +122,12 @@ begins with a hash character
.Ql # , .Ql # ,
it is treated as an inline palette specification. it is treated as an inline palette specification.
It should contain a comma-separated list of hexadecimal colors, each beginning with a hash. It should contain a comma-separated list of hexadecimal colors, each beginning with a hash.
Colors in are accepted in the following formats: Colors in are accepted either as
.Ql #rgb , .Ql #rgb
.Ql #rrggbb , or
and .Ql #rrggbb
.Ql #rrggbbaa . format.
Palettes must be separated by a semicolon (they may require quoting to avoid special handling by the shell), and spaces are allowed around semicolons and commas; trailing commas and semicolons are allowed. Palettes must be separated by a colon or semicolon (the latter may require quoting to avoid special handling by the shell), and spaces are allowed around colons, semicolons and commas; trailing commas and semicolons are allowed.
See See
.Sx EXAMPLES .Sx EXAMPLES
for an example of an inline palette specification. for an example of an inline palette specification.

View File

@@ -128,7 +128,7 @@ void parseInlinePalSpec(char const * const rawArg) {
skipWhitespace(arg, n); skipWhitespace(arg, n);
if (n == arg.length()) { if (n == arg.length()) {
break; break;
} else if (arg[n] != ';') { } else if (arg[n] != ';' && arg[n] != ':') {
if (nbColors == 4) { if (nbColors == 4) {
parseError(n, 1, "Each palette can only contain up to 4 colors"); parseError(n, 1, "Each palette can only contain up to 4 colors");
return; return;
@@ -137,6 +137,7 @@ void parseInlinePalSpec(char const * const rawArg) {
} }
[[fallthrough]]; [[fallthrough]];
case ':':
case ';': case ';':
++n; ++n;
skipWhitespace(arg, n); skipWhitespace(arg, n);
@@ -265,7 +266,6 @@ static void parsePSPFile(std::filebuf &file) {
readLine(file, line); readLine(file, line);
n = 0; n = 0;
// TODO: parse R G B
uint8_t r = parseDec(line, n); uint8_t r = parseDec(line, n);
skipWhitespace(line, n); skipWhitespace(line, n);
if (n == line.length()) { if (n == line.length()) {