diff --git a/src/fix/main.cpp b/src/fix/main.cpp index 8023bd1b..f21b5b25 100644 --- a/src/fix/main.cpp +++ b/src/fix/main.cpp @@ -1197,7 +1197,7 @@ static bool processFilename(char const *name) if (fstat(input, &stat) == -1) { report("FATAL: Failed to stat \"%s\": %s\n", name, strerror(errno)); - } else if (!S_ISREG(stat.st_mode)) { // FIXME: Do we want to support other types? + } else if (!S_ISREG(stat.st_mode)) { // TODO: Do we want to support other types? report("FATAL: \"%s\" is not a regular file, and thus cannot be modified in-place\n", name); } else if (stat.st_size < 0x150) { diff --git a/src/gfx/pal_spec.cpp b/src/gfx/pal_spec.cpp index eec34690..d9497b9d 100644 --- a/src/gfx/pal_spec.cpp +++ b/src/gfx/pal_spec.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -218,21 +219,18 @@ static void readLine(std::filebuf &file, std::string &buffer) { } } -// FIXME: Normally we'd use `std::from_chars`, but that's not available with GCC 7 /* * Parses the initial part of a string_view, advancing the "read index" as it does */ template // Should be uint*_t static std::optional parseDec(std::string const &str, std::string::size_type &n) { - std::string::size_type start = n; - - uintmax_t value = 0; // Use a larger type to handle overflow more easily - for (auto end = std::min(str.length(), str.find_first_not_of("0123456789"sv, n)); n < end; - ++n) { - value = std::min(value * 10 + (str[n] - '0'), (uintmax_t)std::numeric_limits::max); + uintmax_t value = 0; + auto result = std::from_chars(str.data(), str.data() + str.size(), value); + if ((bool)result.ec) { + return std::nullopt; } - - return n > start ? std::optional{value} : std::nullopt; + n += result.ptr - str.data(); + return std::optional{value}; } static std::optional parseColor(std::string const &str, std::string::size_type &n, @@ -334,8 +332,7 @@ static void parseGPLFile(std::filebuf &file) { std::string line; readLine(file, line); - // FIXME: C++20 will allow `!line.starts_with` instead of `line.rfind` with 0 - if (line.rfind("GIMP Palette", 0)) { + if (!line.starts_with("GIMP Palette")) { error("Palette file does not appear to be a GPL palette file"); return; } @@ -350,8 +347,7 @@ static void parseGPLFile(std::filebuf &file) { break; } - // FIXME: C++20 will allow `line.starts_with` instead of `!line.rfind` with 0 - if (!line.rfind("#", 0) || !line.rfind("Name:", 0) || !line.rfind("Column:", 0)) { + if (line.starts_with("#") || line.starts_with("Name:") || line.starts_with("Column:")) { continue; } diff --git a/src/link/main.cpp b/src/link/main.cpp index 86a790f2..07be9f67 100644 --- a/src/link/main.cpp +++ b/src/link/main.cpp @@ -402,7 +402,7 @@ int main(int argc, char *argv[]) parseScrambleSpec(musl_optarg); break; case 's': - // FIXME: nobody knows what this does, figure it out + // TODO: implement "smart linking" with `-s` (void)musl_optarg; warning(NULL, 0, "Nobody has any idea what `-s` does"); break; diff --git a/src/link/output.cpp b/src/link/output.cpp index f5fb9251..35427785 100644 --- a/src/link/output.cpp +++ b/src/link/output.cpp @@ -330,8 +330,8 @@ static int compareSymbols(void const *a, void const *b) char const *sym1_name = sym1->sym->name; char const *sym2_name = sym2->sym->name; - bool sym1_local = !!strchr(sym1_name, '.'); - bool sym2_local = !!strchr(sym2_name, '.'); + bool sym1_local = strchr(sym1_name, '.'); + bool sym2_local = strchr(sym2_name, '.'); if (sym1_local != sym2_local) { size_t sym1_len = strlen(sym1_name);