Mercurial > minori
diff src/core/strings.cc @ 413:192da585a0a8 default tip
*: fix formatting
the clang-format file was broken andjust using LLVM defaults.
now it's fixed and is more in line with what I actually prefer my
code to look like -- esp. with regards to tabulators
| author | Paper <paper@tflc.us> |
|---|---|
| date | Sat, 25 Jul 2026 14:54:32 -0400 |
| parents | 02a670a8e1c4 |
| children |
line wrap: on
line diff
--- a/src/core/strings.cc Sat Jul 25 14:33:03 2026 -0400 +++ b/src/core/strings.cc Sat Jul 25 14:54:32 2026 -0400 @@ -74,15 +74,15 @@ void ConvertRomanNumerals(std::string &string) { static const std::vector<std::pair<std::string_view, std::string_view>> vec = { - {"2", "II" }, + {"2", "II" }, {"3", "III" }, {"4", "IV" }, {"5", "V" }, {"6", "VI" }, {"7", "VII" }, - {"8", "VIII"}, + {"8", "VIII"}, {"9", "IX" }, - {"11", "XI" }, + {"11", "XI" }, {"12", "XII" }, {"13", "XIII"} }; @@ -95,14 +95,14 @@ void NormalizeUnicode(std::string &string) { static constexpr utf8proc_option_t options = static_cast<utf8proc_option_t>( - UTF8PROC_COMPAT | UTF8PROC_COMPOSE | UTF8PROC_STABLE | UTF8PROC_IGNORE | UTF8PROC_STRIPCC | UTF8PROC_STRIPMARK | - UTF8PROC_LUMP | UTF8PROC_CASEFOLD | UTF8PROC_NLF2LS); + UTF8PROC_COMPAT | UTF8PROC_COMPOSE | UTF8PROC_STABLE | UTF8PROC_IGNORE | UTF8PROC_STRIPCC | UTF8PROC_STRIPMARK | + UTF8PROC_LUMP | UTF8PROC_CASEFOLD | UTF8PROC_NLF2LS); /* ack */ utf8proc_uint8_t *buf = nullptr; const utf8proc_ssize_t size = - utf8proc_map(reinterpret_cast<const utf8proc_uint8_t *>(string.data()), string.size(), &buf, options); + utf8proc_map(reinterpret_cast<const utf8proc_uint8_t *>(string.data()), string.size(), &buf, options); if (buf) { if (size) @@ -216,7 +216,8 @@ #if defined(__APPLE__) && defined(__MACH__) CFStringRef ToCFString(const std::string &string) { - return CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(string.data()), string.size(), kCFStringEncodingUTF8, false); + return CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(string.data()), string.size(), + kCFStringEncodingUTF8, false); } std::string ToUtf8String(CFStringRef str) { @@ -230,7 +231,8 @@ range.length = len; range.location = 0; CFIndex used; - CFStringGetBytes(str, range, kCFStringEncodingUTF8, 0, false, reinterpret_cast<UInt8 *>(buf.data()), buf.size(), &used); + CFStringGetBytes( + str, range, kCFStringEncodingUTF8, 0, false, reinterpret_cast<UInt8 *>(buf.data()), buf.size(), &used); buf.resize(used); return buf; } @@ -253,15 +255,15 @@ uint64_t HumanReadableSizeToBytes(const std::string &str) { static const std::unordered_map<std::string, uint64_t> bytes_map = { - {"KB", 1e3 }, + {"KB", 1e3 }, {"MB", 1e6 }, {"GB", 1e9 }, {"TB", 1e12 }, - {"PB", 1e15 }, + {"PB", 1e15 }, {"KiB", 1ull << 10}, {"MiB", 1ull << 20}, - {"GiB", 1ull << 30}, - {"TiB", 1ull << 40}, + {"GiB", 1ull << 30}, + {"TiB", 1ull << 40}, {"PiB", 1ull << 50} /* surely we won't need more than this */ }; @@ -286,7 +288,7 @@ return Strings::ToUtf8String(session.config.locale.GetLocale().formattedDataSize(bytes, precision)); #else static const std::unordered_map<uint64_t, std::string> map = { - {1ull << 10, "KiB"}, + {1ull << 10, "KiB"}, {1ull << 20, "MiB"}, {1ull << 30, "GiB"}, {1ull << 40, "TiB"}, @@ -339,17 +341,17 @@ * * XXX probably better to use case folding here */ static constexpr std::array<std::string_view, 3> suffixes = { - "-dark", /* Adwaita-dark */ - "-Dark", /* Arc-Dark */ - "-Darker", /* Arc-Darker */ + "-dark", /* Adwaita-dark */ + "-Dark", /* Arc-Dark */ + "-Darker", /* Arc-Darker */ }; for (const auto &suffix : suffixes) { if (str.size() < suffix.size()) continue; - if (std::equal(str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), - suffix.end())) + if (std::equal( + str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), suffix.end())) return true; }
