From 4968433a6abecbbf7e72e97188926586a7fd0662 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 16 Mar 2026 12:31:45 -0700 Subject: [PATCH] Minor cleanup --- src/os.cc | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/os.cc b/src/os.cc index 3acd0e3f..409863a9 100644 --- a/src/os.cc +++ b/src/os.cc @@ -61,6 +61,7 @@ namespace { #ifdef _WIN32 + // Return type of read and write functions. using rwresult = int; @@ -69,20 +70,6 @@ using rwresult = int; inline unsigned convert_rwcount(size_t count) { return count <= UINT_MAX ? static_cast(count) : UINT_MAX; } -#elif FMT_USE_FCNTL -// Return type of read and write functions. -using rwresult = ssize_t; - -inline auto convert_rwcount(size_t count) -> size_t { return count; } -#endif -} // namespace - -FMT_BEGIN_NAMESPACE - -#ifdef _WIN32 -namespace detail { - -namespace { class system_message { system_message(const system_message&) = delete; @@ -111,8 +98,8 @@ class system_message { } ~system_message() { LocalFree(message_); } explicit operator bool() const noexcept { return result_ != 0; } - operator basic_string_view() const noexcept { - return basic_string_view(message_, result_); + operator fmt::basic_string_view() const noexcept { + return fmt::basic_string_view(message_, result_); } }; @@ -122,7 +109,7 @@ class utf8_system_category final : public std::error_category { std::string message(int error_code) const override { auto&& msg = system_message(error_code); if (msg) { - auto utf8_message = to_utf8(); + auto utf8_message = fmt::detail::to_utf8(); if (utf8_message.convert(msg)) { return utf8_message.str(); } @@ -131,12 +118,22 @@ class utf8_system_category final : public std::error_category { } }; +#elif FMT_USE_FCNTL + +// Return type of read and write functions. +using rwresult = ssize_t; + +inline auto convert_rwcount(size_t count) -> size_t { return count; } + +#endif } // namespace -} // namespace detail +FMT_BEGIN_NAMESPACE + +#ifdef _WIN32 FMT_API const std::error_category& system_category() noexcept { - static const detail::utf8_system_category category; + static const utf8_system_category category; return category; } @@ -166,6 +163,7 @@ void detail::format_windows_error(detail::buffer& out, int error_code, void report_windows_error(int error_code, const char* message) noexcept { do_report_error(detail::format_windows_error, error_code, message); } + #endif // _WIN32 buffered_file::~buffered_file() noexcept {