From 396729f2e61339c6f737553690bade125b3cf3b8 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sat, 21 Sep 2024 22:18:30 +0200 Subject: [PATCH] Use std::format() API now, instead of fmtlib Signed-off-by: Christian Parpart --- .clang-tidy | 1 - .github/workflows/build.yml | 6 +- .gitignore | 1 + cmake/ThirdParties.cmake | 8 -- scripts/install-deps.sh | 21 +---- src/libunicode/CMakeLists.txt | 2 +- src/libunicode/capi_test.cpp | 3 +- src/libunicode/convert_test.cpp | 3 +- src/libunicode/emoji_segmenter.h | 85 +++++++++---------- src/libunicode/emoji_segmenter_test.cpp | 8 +- src/libunicode/mktables.py | 21 ++--- src/libunicode/run_segmenter_test.cpp | 5 +- src/libunicode/scan.cpp | 2 +- src/libunicode/scan_test.cpp | 15 ++-- .../utf8_grapheme_segmenter_test.cpp | 7 +- src/libunicode/utf8_test.cpp | 23 +++-- src/tools/CMakeLists.txt | 2 +- src/tools/uc-inspect.cpp | 20 ++--- vcpkg.json | 3 +- 19 files changed, 93 insertions(+), 143 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index da126e4..fc462da 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -15,7 +15,6 @@ Checks: >- UseColor: true WarningsAsErrors: true HeaderFilterRegex: '' -AnalyzeTemporaryDtors: false FormatStyle: none CheckOptions: - key: bugprone-easily-swappable-parameters.MinimumLength diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05a57c5..645e576 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: strategy: fail-fast: false matrix: - os_version: ['20.04', '22.04', '24.04'] + os_version: ['24.04'] name: "Ubuntu ${{ matrix.os_version }}" runs-on: ubuntu-${{ matrix.os_version }} steps: @@ -44,8 +44,6 @@ jobs: run: sudo apt -q update - name: "install dependencies" run: ./scripts/install-deps.sh - - name: "create build directory" - run: mkdir build - name: "cmake" run: | cmake -S . -B build -G Ninja \ @@ -77,8 +75,6 @@ jobs: set -ex #brew update ./scripts/install-deps.sh - - name: "Create build directory" - run: mkdir build - name: "Generate build files" run: cmake --preset macos-release - name: "Build" diff --git a/.gitignore b/.gitignore index 335c2bd..809f855 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /out/ /_deps/ /_ucd/ +/.cache/ /.clangd/ /compile_commands.json /.vscode/ diff --git a/cmake/ThirdParties.cmake b/cmake/ThirdParties.cmake index 7624c14..8b4cb46 100644 --- a/cmake/ThirdParties.cmake +++ b/cmake/ThirdParties.cmake @@ -54,13 +54,6 @@ if(LIBUNICODE_BENCHMARK) endif() -if(TARGET fmt) - set(THIRDPARTY_BUILTIN_fmt "embedded") -else() - find_package(fmt REQUIRED) - set(THIRDPARTY_BUILTIN_fmt "system package") -endif() - macro(ThirdPartiesSummary2) message(STATUS "==============================================================================") message(STATUS " ThirdParties") @@ -71,6 +64,5 @@ endif() if(LIBUNICODE_BENCHMARK) message(STATUS "Benchmark ${THIRDPARTY_BUILTIN_benchmark}") endif() - message(STATUS "fmt ${THIRDPARTY_BUILTIN_fmt}") message(STATUS "------------------------------------------------------------------------------") endmacro() diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index 51043a5..52e04db 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -79,14 +79,6 @@ fetch_and_unpack_benchmark() } -fetch_and_unpack_fmtlib() -{ - fetch_and_unpack \ - fmt-9.1.0 \ - fmtlib-9.1.0.tar.gz \ - https://github.com/fmtlib/fmt/archive/refs/tags/9.1.0.tar.gz -} - prepare_fetch_and_unpack() { mkdir -p "${SYSDEPS_BASE_DIR}" @@ -105,7 +97,6 @@ install_deps_ubuntu() cmake debhelper dpkg-dev - g++ libc6-dev make ninja-build @@ -116,12 +107,13 @@ install_deps_ubuntu() local NAME=`grep ^NAME /etc/os-release | cut -d= -f2 | cut -f1 | tr -d '"'` case $RELEASE in - "20.04" | "22.04" | "24.04") - fetch_and_unpack_fmtlib + "24.04") fetch_and_unpack_Catch2 + packages="$packages g++-14" ;; *) - packages="$packages libfmt-dev catch2" + packages="$packages g++" + packages="$packages catch2" ;; esac @@ -142,7 +134,6 @@ install_deps_FreeBSD() su root -c "pkg install $SYSDEP_ASSUME_YES \ catch \ cmake \ - libfmt \ ninja \ pkgconf \ range-v3 @@ -151,7 +142,6 @@ install_deps_FreeBSD() install_deps_arch() { - fetch_and_unpack_fmtlib fetch_and_unpack_benchmark [ x$PREPARE_ONLY_EMBEDS = xON ] && return @@ -170,7 +160,6 @@ install_deps_fedora() local packages=" catch-devel cmake - fmt-devel gcc-c++ google-benchmark-devel ninja-build @@ -193,7 +182,6 @@ install_deps_darwin() # NB: Also available in brew: mimalloc # catch2: available in brew, but too new (version 3+) brew install $SYSDEP_ASSUME_YES \ - fmt \ ninja \ pkg-config \ range-v3 @@ -230,7 +218,6 @@ main() ;; *) fetch_and_unpack_Catch2 - fetch_and_unpack_fmtlib fetch_and_unpack_benchmark echo "OS $ID not supported." echo "Dependencies were fetch manually and most likely libunicode will compile." diff --git a/src/libunicode/CMakeLists.txt b/src/libunicode/CMakeLists.txt index 59dfcee..144939a 100644 --- a/src/libunicode/CMakeLists.txt +++ b/src/libunicode/CMakeLists.txt @@ -242,7 +242,7 @@ if(LIBUNICODE_TESTING) target_include_directories(Catch2 SYSTEM INTERFACE ${CATCH2_INCLUDE_DIRS}) endif() - target_link_libraries(unicode_test unicode Catch2::Catch2WithMain fmt::fmt-header-only) + target_link_libraries(unicode_test unicode Catch2::Catch2WithMain) add_test(unicode_test unicode_test) endif() # }}} diff --git a/src/libunicode/capi_test.cpp b/src/libunicode/capi_test.cpp index 0795b58..64f3071 100644 --- a/src/libunicode/capi_test.cpp +++ b/src/libunicode/capi_test.cpp @@ -13,11 +13,10 @@ */ #include -#include - #include #include +#include #include using namespace std; diff --git a/src/libunicode/convert_test.cpp b/src/libunicode/convert_test.cpp index 616681c..ab0da11 100644 --- a/src/libunicode/convert_test.cpp +++ b/src/libunicode/convert_test.cpp @@ -15,10 +15,9 @@ #include #include -#include - #include +#include #include using namespace unicode; diff --git a/src/libunicode/emoji_segmenter.h b/src/libunicode/emoji_segmenter.h index 4334f14..85b976b 100644 --- a/src/libunicode/emoji_segmenter.h +++ b/src/libunicode/emoji_segmenter.h @@ -15,10 +15,8 @@ #include -#include -#include +#include #include -#include namespace unicode { @@ -129,7 +127,6 @@ inline std::ostream& operator<<(std::ostream& os, EmojiSegmentationCategory valu { switch (value) { - // clang-format off case unicode::EmojiSegmentationCategory::Invalid: return os << "Invalid"; case unicode::EmojiSegmentationCategory::Emoji: return os << "Emoji"; case unicode::EmojiSegmentationCategory::EmojiTextPresentation: return os << "EmojiTextPresentation"; @@ -140,66 +137,62 @@ inline std::ostream& operator<<(std::ostream& os, EmojiSegmentationCategory valu case unicode::EmojiSegmentationCategory::RegionalIndicator: return os << "RegionalIndicator"; case unicode::EmojiSegmentationCategory::KeyCapBase: return os << "KeyCapBase"; case unicode::EmojiSegmentationCategory::CombiningEnclosingKeyCap: return os << "CombiningEnclosingKeyCap"; - case unicode::EmojiSegmentationCategory::CombiningEnclosingCircleBackslash: return os << "CombiningEnclosingCircleBackslash"; + case unicode::EmojiSegmentationCategory::CombiningEnclosingCircleBackslash: + return os << "CombiningEnclosingCircleBackslash"; case unicode::EmojiSegmentationCategory::ZWJ: return os << "ZWJ"; case unicode::EmojiSegmentationCategory::VS15: return os << "VS15"; case unicode::EmojiSegmentationCategory::VS16: return os << "VS16"; case unicode::EmojiSegmentationCategory::TagBase: return os << "TagBase"; case unicode::EmojiSegmentationCategory::TagSequence: return os << "TagSequence"; case unicode::EmojiSegmentationCategory::TagTerm: return os << "TagTerm"; - // clang-format off } return os; } } // namespace unicode -// clang-format off -#if __has_include() -#include -#if FMT_VERSION >= (9 * 10000 + 1 * 100 + 0) -template <> struct fmt::formatter: fmt::ostream_formatter {}; - - -namespace fmt -{ template <> -struct formatter +struct std::formatter: std::formatter { - template - constexpr auto parse(ParseContext& ctx) + auto format(unicode::PresentationStyle value, auto& ctx) const { - return ctx.begin(); + string_view name; + switch (value) + { + case unicode::PresentationStyle::Text: name = "Text"; break; + case unicode::PresentationStyle::Emoji: name = "Emoji"; break; + } + return formatter::format(name, ctx); } - template - auto format(unicode::EmojiSegmentationCategory value, FormatContext& ctx) +}; + +template <> +struct std::formatter: std::formatter +{ + auto format(unicode::EmojiSegmentationCategory value, auto& ctx) const { + using unicode::EmojiSegmentationCategory; + string_view name; switch (value) { - // clang-format off - case unicode::EmojiSegmentationCategory::Invalid: return fmt::format_to(ctx.out(), "Invalid"); - case unicode::EmojiSegmentationCategory::Emoji: return fmt::format_to(ctx.out(), "Emoji"); - case unicode::EmojiSegmentationCategory::EmojiTextPresentation: return fmt::format_to(ctx.out(), "EmojiTextPresentation"); - case unicode::EmojiSegmentationCategory::EmojiEmojiPresentation: return fmt::format_to(ctx.out(), "EmojiEmojiPresentation"); - case unicode::EmojiSegmentationCategory::EmojiModifierBase: return fmt::format_to(ctx.out(), "EmojiModifierBase"); - case unicode::EmojiSegmentationCategory::EmojiModifier: return fmt::format_to(ctx.out(), "EmojiModifier"); - case unicode::EmojiSegmentationCategory::EmojiVSBase: return fmt::format_to(ctx.out(), "EmojiVSBase"); - case unicode::EmojiSegmentationCategory::RegionalIndicator: return fmt::format_to(ctx.out(), "RegionalIndicator"); - case unicode::EmojiSegmentationCategory::KeyCapBase: return fmt::format_to(ctx.out(), "KeyCapBase"); - case unicode::EmojiSegmentationCategory::CombiningEnclosingKeyCap: return fmt::format_to(ctx.out(), "CombiningEnclosingKeyCap"); - case unicode::EmojiSegmentationCategory::CombiningEnclosingCircleBackslash: return fmt::format_to(ctx.out(), "CombiningEnclosingCircleBackslash"); - case unicode::EmojiSegmentationCategory::ZWJ: return fmt::format_to(ctx.out(), "ZWJ"); - case unicode::EmojiSegmentationCategory::VS15: return fmt::format_to(ctx.out(), "VS15"); - case unicode::EmojiSegmentationCategory::VS16: return fmt::format_to(ctx.out(), "VS16"); - case unicode::EmojiSegmentationCategory::TagBase: return fmt::format_to(ctx.out(), "TagBase"); - case unicode::EmojiSegmentationCategory::TagSequence: return fmt::format_to(ctx.out(), "TagSequence"); - case unicode::EmojiSegmentationCategory::TagTerm: return fmt::format_to(ctx.out(), "TagTerm"); - // clang-format off + case EmojiSegmentationCategory::Invalid: name = "Invalid"; break; + case EmojiSegmentationCategory::Emoji: name = "Emoji"; break; + case EmojiSegmentationCategory::EmojiTextPresentation: name = "EmojiTextPresentation"; break; + case EmojiSegmentationCategory::EmojiEmojiPresentation: name = "EmojiEmojiPresentation"; break; + case EmojiSegmentationCategory::EmojiModifierBase: name = "EmojiModifierBase"; break; + case EmojiSegmentationCategory::EmojiModifier: name = "EmojiModifier"; break; + case EmojiSegmentationCategory::EmojiVSBase: name = "EmojiVSBase"; break; + case EmojiSegmentationCategory::RegionalIndicator: name = "RegionalIndicator"; break; + case EmojiSegmentationCategory::KeyCapBase: name = "KeyCapBase"; break; + case EmojiSegmentationCategory::CombiningEnclosingKeyCap: name = "CombiningEnclosingKeyCap"; break; + case EmojiSegmentationCategory::CombiningEnclosingCircleBackslash: name = "CombiningEnclosingCircleBackslash"; break; + case EmojiSegmentationCategory::ZWJ: name = "ZWJ"; break; + case EmojiSegmentationCategory::VS15: name = "VS15"; break; + case EmojiSegmentationCategory::VS16: name = "VS16"; break; + case EmojiSegmentationCategory::TagBase: name = "TagBase"; break; + case EmojiSegmentationCategory::TagSequence: name = "TagSequence"; break; + case EmojiSegmentationCategory::TagTerm: name = "TagTerm"; break; } - return fmt::format_to(ctx.out(), "({})", unsigned(value)); -} + return formatter::format(name, ctx); + } }; -} -#endif -#endif -// clang-format on diff --git a/src/libunicode/emoji_segmenter_test.cpp b/src/libunicode/emoji_segmenter_test.cpp index d094a8c..38fa5f7 100644 --- a/src/libunicode/emoji_segmenter_test.cpp +++ b/src/libunicode/emoji_segmenter_test.cpp @@ -16,10 +16,10 @@ #include #include -#include - #include +#include + using namespace unicode; using namespace std::string_literals; using namespace std; @@ -46,14 +46,14 @@ void test_segments(int lineNo, std::vector\n') self.file.write('\n') - self.file.write('#include \n') + self.file.write('#include \n') self.file.write('\n') - self.file.write('namespace fmt\n{\n\n') def begin(self, _enum_class, _first): self.enum_class = 'unicode::' + _enum_class self.file.write('template <>\n') - self.file.write('struct formatter<{}>\n{{\n'.format(self.enum_class)) - - self.file.write(' template \n') - self.file.write(' constexpr auto parse(ParseContext& ctx)\n') - self.file.write(' {\n') - self.file.write(' return ctx.begin();\n') - self.file.write(' }\n') - - self.file.write(' template \n') - self.file.write(' auto format({} value, FormatContext& ctx)\n'.format(self.enum_class)) + self.file.write('struct std::formatter<{}>: std::formatter\n{{\n'.format(self.enum_class)) + self.file.write(' auto format({} value, auto& ctx) const\n'.format(self.enum_class)) self.file.write(' {\n') + self.file.write(' std::string_view name;\n') self.file.write(' switch (value)\n') self.file.write(' {\n') self.file.write(' // clang-format off\n') def member(self, _member): self.file.write( - ' case {0}::{1}: return fmt::format_to(ctx.out(), "{2}");\n'.format( + ' case {0}::{1}: name = "{2}"; break;\n'.format( self.enum_class, sanitize_identifier(_member), _member) ) def end(self): self.file.write(' // clang-format off\n') self.file.write(" }\n") - self.file.write(' return fmt::format_to(ctx.out(), "({})", unsigned(value));\n') + self.file.write(' return formatter::format(name, ctx);\n') self.file.write(" }\n") self.file.write("};\n\n") @@ -251,7 +243,6 @@ def output(self): return self.filename def close(self): - self.file.write("} // namespace fmt\n") self.file.close() # }}} class MergedRange: # {{{ diff --git a/src/libunicode/run_segmenter_test.cpp b/src/libunicode/run_segmenter_test.cpp index 52b9c8f..0a83478 100644 --- a/src/libunicode/run_segmenter_test.cpp +++ b/src/libunicode/run_segmenter_test.cpp @@ -15,12 +15,11 @@ #include #include -#include -#include - #include #include +#include +#include #include #include #include diff --git a/src/libunicode/scan.cpp b/src/libunicode/scan.cpp index 7e197f4..8efbbad 100644 --- a/src/libunicode/scan.cpp +++ b/src/libunicode/scan.cpp @@ -131,7 +131,7 @@ size_t detail::scan_for_text_ascii(string_view text, size_t maxColumnCount) noex ++input; // if (static_cast(distance(text.data(), input))) - // fmt::print( + // std::print( // "countAsciiTextChars: {} bytes: \"{}\"\n", // static_cast(distance(text.data(), input)), // (string_view(text.data(), static_cast(distance(text.data(), input))))); diff --git a/src/libunicode/scan_test.cpp b/src/libunicode/scan_test.cpp index 57f28da..240e754 100644 --- a/src/libunicode/scan_test.cpp +++ b/src/libunicode/scan_test.cpp @@ -15,10 +15,9 @@ #include #include -#include - #include +#include #include using std::string_view; @@ -52,11 +51,11 @@ std::string escape(uint8_t ch) case '"': return "\\\""; default: if (ch < 0x20) - return fmt::format("\\{:03o}", static_cast(ch) & 0xFF); + return std::format("\\{:03o}", static_cast(ch) & 0xFF); else if (ch < 0x80) - return fmt::format("{}", static_cast(ch)); + return std::format("{}", static_cast(ch)); else - return fmt::format("\\x{:02x}", static_cast(ch) & 0xFF); + return std::format("\\x{:02x}", static_cast(ch) & 0xFF); } } @@ -238,7 +237,7 @@ TEST_CASE("scan.any.ascii_complex_repeat") auto const countSimple = ((i + 1) / 2) * 20; auto const countComplex = (i / 2) * 2; - INFO(fmt::format("i = {}, ascii# {}, complex# {}, count {}, actual {}, s = \"{}\"", + INFO(std::format("i = {}, ascii# {}, complex# {}, count {}, actual {}, s = \"{}\"", i, countSimple, countComplex, @@ -340,7 +339,7 @@ void testScanText(int lineNo, uint8_t stopByte, std::vector const& analyzedGraphemeClusters) { - INFO(fmt::format("Testing scan segment from line {}: {} ({:02X})", lineNo, hex(expectation), stopByte)); + INFO(std::format("Testing scan segment from line {}: {} ({:02X})", lineNo, hex(expectation), stopByte)); auto const maxColumnCount = 80; std::string fullText; @@ -363,7 +362,7 @@ void testScanText(int lineNo, auto const iMax = std::min(analyzedGraphemeClusters.size(), graphemeClusterCollector.output.size()); for (size_t i = 0; i < iMax; ++i) { - INFO(fmt::format("i: {}, lhs: {}, rhs: {}", + INFO(std::format("i: {}, lhs: {}, rhs: {}", i, u8(std::u32string_view(graphemeClusterCollector.output[i].data(), graphemeClusterCollector.output[i].size())), diff --git a/src/libunicode/utf8_grapheme_segmenter_test.cpp b/src/libunicode/utf8_grapheme_segmenter_test.cpp index f4b220f..9c048a6 100644 --- a/src/libunicode/utf8_grapheme_segmenter_test.cpp +++ b/src/libunicode/utf8_grapheme_segmenter_test.cpp @@ -13,10 +13,9 @@ */ #include -#include - #include +#include #include using namespace std::string_literals; @@ -32,7 +31,7 @@ std::string escape(std::string const& s) if (std::isprint(ch)) t += ch; else - t += fmt::format("\\x{:02X}", ((unsigned) ch) & 0xFF); + t += std::format("\\x{:02X}", ((unsigned) ch) & 0xFF); return t; } @@ -51,7 +50,7 @@ void test_utf8_grapheme_cluster_segmentation(Ts... expects) }; auto const checkOne = [&](std::u32string_view expected) -> void { - INFO(fmt::format("expects: {}, actual {}", s8(expected), s8(*i))); + INFO(std::format("expects: {}, actual {}", s8(expected), s8(*i))); REQUIRE(s8(*i) == s8(expected)); REQUIRE(i != e); ++i; diff --git a/src/libunicode/utf8_test.cpp b/src/libunicode/utf8_test.cpp index 9c04977..51baf31 100644 --- a/src/libunicode/utf8_test.cpp +++ b/src/libunicode/utf8_test.cpp @@ -14,13 +14,12 @@ #include #include -#include - #include #include #include #include +#include #include using namespace std; @@ -54,20 +53,20 @@ TEST_CASE("utf8.bytes_1", "[utf8]") auto const r1 = from_utf8(state, C); REQUIRE(holds_alternative(r1)); char32_t const b = get(r1).value; - INFO(fmt::format("char32_t : 0x{:04X}", (unsigned) b)); + INFO(std::format("char32_t : 0x{:04X}", (unsigned) b)); REQUIRE(b == C); } TEST_CASE("utf8.bytes_2", "[utf8]") { char32_t constexpr C { 0xF6 }; // 0xC3 0xB6, 'ö' - INFO(fmt::format("codepoint : 0x{:04X}", (unsigned) C)); + INFO(std::format("codepoint : 0x{:04X}", (unsigned) C)); // encode uint8_t actual[2] = {}; auto const count = to_utf8(C, actual); - INFO(fmt::format("utf8 : {:X} {:X}", actual[0], actual[1])); - INFO(fmt::format("binary : {} {}", binstr(actual[0]), binstr(actual[1]))); + INFO(std::format("utf8 : {:X} {:X}", actual[0], actual[1])); + INFO(std::format("binary : {} {}", binstr(actual[0]), binstr(actual[1]))); REQUIRE(count == 2); CHECK(actual[0] == 0xC3); CHECK(actual[1] == 0xB6); @@ -77,7 +76,7 @@ TEST_CASE("utf8.bytes_2", "[utf8]") auto const a = from_utf8(actual, &len); REQUIRE(holds_alternative(a)); char32_t b = get(a).value; - INFO(fmt::format("char32_t : 0x{:04X} ==? 0x{:04X}", (unsigned) b, (unsigned) C)); + INFO(std::format("char32_t : 0x{:04X} ==? 0x{:04X}", (unsigned) b, (unsigned) C)); REQUIRE(b == C); } @@ -91,15 +90,15 @@ TEST_CASE("utf8.bytes_3", "[utf8]") CHECK(b3[1] == 0x82); CHECK(b3[2] == 0xAC); - INFO(fmt::format("{:02X} {:02X} {:02X}", b3[0], b3[1], b3[2])); - INFO(fmt::format("{} {} {}", binstr(b3[0]), binstr(b3[1]), binstr(b3[2]))); + INFO(std::format("{:02X} {:02X} {:02X}", b3[0], b3[1], b3[2])); + INFO(std::format("{} {} {}", binstr(b3[0]), binstr(b3[1]), binstr(b3[2]))); // decode size_t len = 0; auto const a = from_utf8(b3, &len); REQUIRE(holds_alternative(a)); char32_t const b = get(a).value; - INFO(fmt::format("char32_t : 0x{:04X}", (unsigned) b)); + INFO(std::format("char32_t : 0x{:04X}", (unsigned) b)); REQUIRE(b == 0x20AC); } @@ -114,8 +113,8 @@ TEST_CASE("utf8.bytes_3_dash", "[utf8]") CHECK(d3[1] == 0x94); CHECK(d3[2] == 0x9C); - INFO(fmt::format("{:02X} {:02X} {:02X}", d3[0], d3[1], d3[2])); - INFO(fmt::format("{} {} {}", binstr(d3[0]), binstr(d3[1]), binstr(d3[2]))); + INFO(std::format("{:02X} {:02X} {:02X}", d3[0], d3[1], d3[2])); + INFO(std::format("{} {} {}", binstr(d3[0]), binstr(d3[1]), binstr(d3[2]))); // decode auto constexpr u8s = array { 0xe2, 0x94, 0x9c, 0x61 /*a*/ }; diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index dae663b..19f2d17 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,6 +1,6 @@ if(LIBUNICODE_TOOLS) add_executable(unicode-query unicode-query.cpp) - target_link_libraries(unicode-query unicode fmt::fmt-header-only) + target_link_libraries(unicode-query unicode) if(LIBUNICODE_BUILD_STATIC) target_link_libraries(unicode-query "-static") endif() diff --git a/src/tools/uc-inspect.cpp b/src/tools/uc-inspect.cpp index d9bed7d..1ad3157 100644 --- a/src/tools/uc-inspect.cpp +++ b/src/tools/uc-inspect.cpp @@ -20,10 +20,8 @@ #include #include -#include -#include - #include +#include #include #include #include @@ -93,9 +91,9 @@ inline string escape(uint8_t ch) case '"': return "\\\""; default: if (std::isprint(static_cast(ch))) - return fmt::format("{}", static_cast(ch)); + return std::format("{}", static_cast(ch)); else - return fmt::format("\\x{:02X}", static_cast(ch) & 0xFF); + return std::format("\\x{:02X}", static_cast(ch) & 0xFF); } } @@ -154,7 +152,7 @@ void codepoints(istream& in) // {{{ { string const u8 = escape(unicode::to_utf8(wc)); - cout << fmt::format("{:>3}: U+{:08X} [{}] [{:<10}] {} width:{} UTF8:{}\n", + cout << std::format("{:>3}: U+{:08X} [{}] [{:<10}] {} width:{} UTF8:{}\n", lastOffset, static_cast(wc), isEmoji(wc) ? "EMOJI" : "TEXT ", @@ -185,7 +183,7 @@ string scriptExtensionsString(char32_t codepoint) { if (i) sstr << ", "; - sstr << fmt::format("{}", scripts[i]); + sstr << std::format("{}", scripts[i]); } return sstr.str(); } @@ -204,11 +202,11 @@ int scripts(istream& in) // {{{ cout << " INDEX CODEPOINT TEXT WIDTH SCRIPT SCRIPT EXTS\n"; while (segmenter.consume(out(nextPosition), out(script))) { - cout << fmt::format("{}-{}: {}\n", frontPosition, nextPosition - 1, script); + cout << std::format("{}-{}: {}\n", frontPosition, nextPosition - 1, script); for (size_t i = frontPosition; i < nextPosition; ++i) { auto const cp = codepoints[i]; - cout << fmt::format(" {:>04}: U+{:08X} {}\t∆ {}\t{:<12}\t({})\n", + cout << std::format(" {:>04}: U+{:08X} {}\t∆ {}\t{:<12}\t({})\n", i, unsigned(cp), convert_to(cp), @@ -235,7 +233,7 @@ int runs(istream& in) // {{{ auto const script = get(run.properties); auto const presentationStyle = get(run.properties); - cout << fmt::format("{}-{} ({}): {} {}\n", run.start, run.end - 1, run.end - run.start, script, presentationStyle); + cout << std::format("{}-{} ({}): {} {}\n", run.start, run.end - 1, run.end - run.start, script, presentationStyle); auto const text32 = u32string_view(codepoints.data() + run.start, run.end - run.start); auto const text8 = convert_to(text32); auto const textEscaped = replaceAll("\033"sv, "\\033"sv, string_view(text8)); @@ -315,7 +313,7 @@ int main(int argc, char const* argv[]) } catch (std::exception const& e) { - std::cerr << fmt::format("Unhandled exception caught ({}). {}\n", typeid(e).name(), e.what()); + std::cerr << std::format("Unhandled exception caught ({}). {}\n", typeid(e).name(), e.what()); return EXIT_FAILURE; } catch (...) diff --git a/vcpkg.json b/vcpkg.json index 3582dbc..d0a7089 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,7 +3,6 @@ "builtin-baseline": "80403036a665cb8fcc1a1b3e17593d20b03b2489", "dependencies": [ { "name": "benchmark", "version>=": "1.8.3" }, - { "name": "catch2", "version>=": "3.4.0" }, - { "name": "fmt", "version>=": "10.2.0" } + { "name": "catch2", "version>=": "3.4.0" } ] }