diff --git a/src/gfx/pal_spec.cpp b/src/gfx/pal_spec.cpp index ffd5deaa..b6ff8783 100644 --- a/src/gfx/pal_spec.cpp +++ b/src/gfx/pal_spec.cpp @@ -352,24 +352,30 @@ static void parseGPLFile(std::filebuf &file) { } uint16_t nbColors = 0; - uint16_t maxNbColors = options.nbColorsPerPal * options.nbPalettes; + uint16_t const maxNbColors = options.nbColorsPerPal * options.nbPalettes; for (;;) { line.clear(); - requireLine("GPL", file, line); - if (!line.length()) { + if (!readLine(file, line)) { break; } - - if (line.starts_with("#") || line.starts_with("Name:") || line.starts_with("Column:")) { + if (line.starts_with("Name:") || line.starts_with("Columns:")) { continue; } std::string::size_type n = 0; + skipWhitespace(line, n); + // Skip empty lines, or lines that contain just a comment. + if (line.length() == n || line[n] == '#') { + continue; + } + std::optional color = parseColor(line, n, nbColors + 1); if (!color) { return; } + // Ignore anything following the three components + // (sometimes it's a comment, sometimes it's the color in CSS hex format, sometimes there's nothing...). if (nbColors < maxNbColors) { if (nbColors % options.nbColorsPerPal == 0) { @@ -394,7 +400,7 @@ static void parseHEXFile(std::filebuf &file) { // https://lospec.com/palette-list/tag/gbc uint16_t nbColors = 0; - uint16_t maxNbColors = options.nbColorsPerPal * options.nbPalettes; + uint16_t const maxNbColors = options.nbColorsPerPal * options.nbPalettes; for (;;) { std::string line; diff --git a/test/gfx/full_gpl.flags b/test/gfx/full_gpl.flags new file mode 100644 index 00000000..cb00ec0f --- /dev/null +++ b/test/gfx/full_gpl.flags @@ -0,0 +1 @@ +-c gpl:full_gpl.gpl diff --git a/test/gfx/full_gpl.gpl b/test/gfx/full_gpl.gpl new file mode 100644 index 00000000..70ab20c2 --- /dev/null +++ b/test/gfx/full_gpl.gpl @@ -0,0 +1,36 @@ +GIMP Palette +#Palette Name: AxulArt 32 color Palette +#Description: 32-color palette, intended to be similar to that used in arcade and Game Boy Advance games; You can see more of my art at: https://axulart.tumblr.com/ and https://axulart.itch.io/ +#Colors: 32 +0 0 0 000000 +252 252 252 fcfcfc +196 199 238 c4c7ee +154 143 224 9a8fe0 +99 93 150 635d96 +41 47 101 292f65 +27 29 52 1b1d34 +255 227 174 ffe3ae +205 187 171 cdbbab +166 133 143 a6858f +207 93 139 cf5d8b +150 73 104 964968 +255 180 130 ffb482 +221 134 125 dd867d +178 105 111 b2696f +246 198 94 f6c65e +228 144 87 e49057 +196 104 51 c46833 +176 208 126 b0d07e +102 170 93 66aa5d +82 181 171 52b5ab +42 131 121 2a8379 +28 86 89 1c5659 +123 225 246 7be1f6 +88 159 252 589ffc +80 105 228 5069e4 +46 68 174 2e44ae +128 86 212 8056d4 +90 59 150 5a3b96 +255 186 225 ffbae1 +230 135 197 e687c5 +167 89 185 a759b9 diff --git a/test/gfx/full_gpl.png b/test/gfx/full_gpl.png new file mode 100644 index 00000000..de5a5849 Binary files /dev/null and b/test/gfx/full_gpl.png differ