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; +}