From 1f8f28cac8e36ad69e4370b3ae7b0a8dc79cf19c Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Fri, 26 Jul 2024 19:36:26 +0200 Subject: [PATCH] Fix parsing of textual colours `n`'s input value was not honored, and its updating logic incorrect --- src/gfx/pal_spec.cpp | 6 +++--- test/gfx/truncated_gpl.err | 2 -- test/gfx/truncated_gpl.flags | 1 - test/gfx/truncated_gpl.gpl | 1 - test/gfx/truncated_gpl.png | Bin 712 -> 0 bytes 5 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 test/gfx/truncated_gpl.err delete mode 100644 test/gfx/truncated_gpl.flags delete mode 100644 test/gfx/truncated_gpl.gpl delete mode 100644 test/gfx/truncated_gpl.png diff --git a/src/gfx/pal_spec.cpp b/src/gfx/pal_spec.cpp index 484b57b8..ffd5deaa 100644 --- a/src/gfx/pal_spec.cpp +++ b/src/gfx/pal_spec.cpp @@ -240,11 +240,11 @@ static bool readLine(std::filebuf &file, std::string &buffer) { template // Should be uint*_t static std::optional parseDec(std::string const &str, std::string::size_type &n) { uintmax_t value = 0; - auto result = std::from_chars(str.data(), str.data() + str.size(), value); - if ((bool)result.ec) { + auto result = std::from_chars(str.data() + n, str.data() + str.size(), value); + if (static_cast(result.ec)) { return std::nullopt; } - n += result.ptr - str.data(); + n = result.ptr - str.data(); return std::optional{value}; } diff --git a/test/gfx/truncated_gpl.err b/test/gfx/truncated_gpl.err deleted file mode 100644 index 1ee64920..00000000 --- a/test/gfx/truncated_gpl.err +++ /dev/null @@ -1,2 +0,0 @@ -error: GPL palette file appears to be truncated -Conversion aborted after 1 error diff --git a/test/gfx/truncated_gpl.flags b/test/gfx/truncated_gpl.flags deleted file mode 100644 index 102b83ef..00000000 --- a/test/gfx/truncated_gpl.flags +++ /dev/null @@ -1 +0,0 @@ --c gpl:truncated_gpl.gpl diff --git a/test/gfx/truncated_gpl.gpl b/test/gfx/truncated_gpl.gpl deleted file mode 100644 index ab477b6a..00000000 --- a/test/gfx/truncated_gpl.gpl +++ /dev/null @@ -1 +0,0 @@ -GIMP Palette diff --git a/test/gfx/truncated_gpl.png b/test/gfx/truncated_gpl.png deleted file mode 100644 index 57fdd36f50ceea06ff1b3c6d58a745fd05c30f13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 712 zcmV;(0yq7MP)EX>4Tx04R}tkv&MmKp2MKrk09SMA|{bAwzYtAS&XhRVYG*P%E_RU~=gnG%+M8 zE{=k0!NH%!s)LKOt`4q(Aov5~=;Wm6A|-y86k5c1$8itueecWNcYx5SGR^8512o+> zGpVGQ%dd#xSA-BnKh3zzEMr!Z((oN$_XzO)F2S?>>;4?QYQbVaKqQ`FhG`S86Hjg0 z2Iqa^7%R&v@j3CRNf#u3)BVfh)c3-)I2SpQP8@ zTKov;+XgPK+nTZmT zjFc#Q&F9_SoqhYarq#b6S`%`eYNz2J00009a7bBm001r{001r{0eGc9b^rhX>PbXF zR7l6oRxu94APfX6FR7F+eM^=MRi9XOV98s$G*Z7phDeo*iERvt;w{0tGv_nlV~p-U zUhnkJR@`r1%mFjHG8tT5h#X)pUm4(bjs^t$zPoyYFw6mcKEGGI>ak6gJqW|hCtwaJ z^|gq8w2QhTt*czbmv2MgWeyS-L0fSWbQOUfeVlr#b2Ev?skijN+}jKRow9oL!%tJZ zi6-S|cCd1^LeER2Ir2__qtSun&CZ0U?;;$J%O{JTGzl*y3JU~34rT4Me=