From b20bdcebfa7c9ffaec6ba36cdb57482228e0fbd9 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 31 May 2019 09:31:11 -0700 Subject: [PATCH] FLOG narrow-string output to use fwprintf This avoids mixing narrow and wide I/O on the same stream. Extends the fix in #5900 by allowing narrow string literals again. --- src/flog.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/flog.cpp b/src/flog.cpp index 4bf94aca8..89ef71bc0 100644 --- a/src/flog.cpp +++ b/src/flog.cpp @@ -34,10 +34,16 @@ logger_t::logger_t() : file_(stderr) {} owning_lock g_logger; void logger_t::log1(const wchar_t *s) { std::fputws(s, file_); } -void logger_t::log1(const char *s) { std::fputs(s, file_); } + +void logger_t::log1(const char *s) { + // Note glibc prohibits mixing narrow and wide I/O, so always use wide-printing functions. + // See #5900. + std::fwprintf(file_, L"%s", s); +} void logger_t::log1(wchar_t c) { std::fputwc(c, file_); } -void logger_t::log1(char c) { std::fputc(c, file_); } + +void logger_t::log1(char c) { std::fwprintf(file_, L"%c", c); } void logger_t::log_fmt(const category_t &cat, const wchar_t *fmt, ...) { va_list va;