From d0f6f8a7b9e5853d45123901dc827995945545aa Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Tue, 22 Sep 2026 05:52:23 +0000 Subject: [PATCH] Match MSL wide stream orientation --- configure.py | 2 +- libs/MSL/src/MSL_Common/wchar_io.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 libs/MSL/src/MSL_Common/wchar_io.c diff --git a/configure.py b/configure.py index 645fa269..78a4278e 100644 --- a/configure.py +++ b/configure.py @@ -1971,7 +1971,7 @@ config.libs = [ Object(Matching, "MSL_Common/wmem.c"), Object(NonMatching, "MSL_Common/wprintf.c"), Object(NonMatching, "MSL_Common/wstring.c"), - Object(NonMatching, "MSL_Common/wchar_io.c"), + Object(Matching, "MSL_Common/wchar_io.c"), Object(Matching, "PPC_EABI/time.dolphin.c"), Object(Matching, "PPC_EABI/sysenv.GCN.c"), Object(Matching, "PPC_EABI/uart_console_io_gcn.c"), diff --git a/libs/MSL/src/MSL_Common/wchar_io.c b/libs/MSL/src/MSL_Common/wchar_io.c new file mode 100644 index 00000000..fa0d613b --- /dev/null +++ b/libs/MSL/src/MSL_Common/wchar_io.c @@ -0,0 +1,44 @@ +#include "internal/file_struct.h" + +enum file_kinds { + file_closed +}; + +enum file_orientation { + file_unoriented, + file_char_oriented, + file_wide_oriented +}; + +int fwide(FILE* file, int file_mode) { + int orientation; + int res; + + if (file == NULL || file->mode.file_kind == file_closed) { + return 0; + } + + orientation = file->mode.file_orientation; + + switch (orientation) { + case file_unoriented: + if (file_mode > 0) { + file->mode.file_orientation = file_wide_oriented; + } else if (file_mode < 0) { + file->mode.file_orientation = file_char_oriented; + } + + res = file_mode; + break; + + case file_wide_oriented: + res = 1; + break; + + case file_char_oriented: + res = -1; + break; + } + + return res; +} -- 2.49.1