@@ -1425,16 +1425,13 @@ FMT_FUNC std::string vformat(string_view fmt, format_args args) {
1425
1425
1426
1426
namespace detail {
1427
1427
#if !defined(_WIN32) || defined(FMT_WINDOWS_NO_WCHAR)
1428
- FMT_FUNC bool write_console (std::FILE* , string_view) { return false ; }
1428
+ FMT_FUNC bool write_console (int /* fd */ , string_view /* text */ ) { return false ; }
1429
1429
#else
1430
1430
using dword = conditional_t <sizeof (long ) == 4 , unsigned long , unsigned >;
1431
1431
extern " C" __declspec(dllimport) int __stdcall WriteConsoleW ( //
1432
1432
void *, const void *, dword, dword*, void *);
1433
1433
1434
- FMT_FUNC bool write_console (std::FILE* f, string_view text) {
1435
- int fd = _fileno (f);
1436
- if (!_isatty (fd)) return false ;
1437
- std::fflush (f);
1434
+ FMT_FUNC bool write_console (int fd, string_view text) {
1438
1435
auto u16 = utf8_to_utf16 (text);
1439
1436
return WriteConsoleW (reinterpret_cast <void *>(_get_osfhandle (fd)), u16.c_str (),
1440
1437
static_cast <dword>(u16.size ()), nullptr , nullptr ) != 0 ;
@@ -1451,7 +1448,14 @@ FMT_FUNC void vprint_mojibake(std::FILE* f, string_view fmt, format_args args) {
1451
1448
#endif
1452
1449
1453
1450
FMT_FUNC void print (std::FILE* f, string_view text) {
1454
- if (!write_console (f, text)) fwrite_fully (text.data (), text.size (), f);
1451
+ #ifdef _WIN32
1452
+ int fd = _fileno (f);
1453
+ if (_isatty (fd)) {
1454
+ std::fflush (f);
1455
+ if (write_console (fd, text)) return ;
1456
+ }
1457
+ #endif
1458
+ fwrite_fully (text.data (), text.size (), f);
1455
1459
}
1456
1460
} // namespace detail
1457
1461
0 commit comments