mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
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
This commit is contained in:
@ -18,7 +18,7 @@
|
|||||||
# include <locale>
|
# include <locale>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(FMT_WINDOWS_NO_WCHAR)
|
#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)
|
||||||
# include <io.h> // _isatty
|
# include <io.h> // _isatty
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1639,7 +1639,7 @@ class file_print_buffer : public buffer<char> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#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; }
|
FMT_FUNC auto write_console(int, string_view) -> bool { return false; }
|
||||||
#else
|
#else
|
||||||
using dword = conditional_t<sizeof(long) == 4, unsigned long, unsigned>;
|
using dword = conditional_t<sizeof(long) == 4, unsigned long, unsigned>;
|
||||||
@ -1665,7 +1665,7 @@ FMT_FUNC void vprint_mojibake(std::FILE* f, string_view fmt, format_args args,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
FMT_FUNC void print(std::FILE* f, string_view text) {
|
FMT_FUNC void print(std::FILE* f, string_view text) {
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)
|
||||||
int fd = _fileno(f);
|
int fd = _fileno(f);
|
||||||
if (_isatty(fd)) {
|
if (_isatty(fd)) {
|
||||||
std::fflush(f);
|
std::fflush(f);
|
||||||
|
@ -344,7 +344,7 @@ TEST(format_impl_test, write_dragon_even) {
|
|||||||
if (!FMT_MSC_VERSION) EXPECT_EQ(s, "33554450");
|
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 <windows.h>
|
# include <windows.h>
|
||||||
|
|
||||||
TEST(format_impl_test, write_console_signature) {
|
TEST(format_impl_test, write_console_signature) {
|
||||||
|
Reference in New Issue
Block a user