[codex] Match MSL wide stream orientation #121

Merged
coah80 merged 1 commits from agent/continue-0922/tools-wchar into main 2026-09-22 05:53:53 +00:00
2 changed files with 45 additions and 1 deletions

View File

@@ -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"),

View File

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