From 13cfaa2ab03d681dc27ee23ae7e675842f32e337 Mon Sep 17 00:00:00 2001 From: mtillmann0 <111434011+mtillmann0@users.noreply.github.com> Date: Fri, 8 Mar 2024 22:34:46 +0100 Subject: [PATCH] Guard against usage of _isatty when header was not included (#3880) * Guard against usage of _isatty when header was not included * Rename FMT_WINDOWS_NO_WCHAR macro to FMT_USE_WRITE_CONSOLE --- include/fmt/format-inl.h | 6 +++--- test/format-impl-test.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index c5259ba4..5a9afd1f 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -18,7 +18,7 @@ # include #endif -#if defined(_WIN32) && !defined(FMT_WINDOWS_NO_WCHAR) +#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE) # include // _isatty #endif @@ -1639,7 +1639,7 @@ class file_print_buffer : public buffer { } }; -#if !defined(_WIN32) || defined(FMT_WINDOWS_NO_WCHAR) +#if !defined(_WIN32) || defined(FMT_USE_WRITE_CONSOLE) FMT_FUNC auto write_console(int, string_view) -> bool { return false; } #else using dword = conditional_t; @@ -1665,7 +1665,7 @@ FMT_FUNC void vprint_mojibake(std::FILE* f, string_view fmt, format_args args, #endif FMT_FUNC void print(std::FILE* f, string_view text) { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE) int fd = _fileno(f); if (_isatty(fd)) { std::fflush(f); diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index eda1f239..9645f832 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -344,7 +344,7 @@ TEST(format_impl_test, write_dragon_even) { if (!FMT_MSC_VERSION) EXPECT_EQ(s, "33554450"); } -#if defined(_WIN32) && !defined(FMT_WINDOWS_NO_WCHAR) +#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE) # include TEST(format_impl_test, write_console_signature) {