[libc-commits] [libc] [libc] Ignore unknown characters after the fopen mode (PR #236968)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri Nov 6 12:56:32 PST 2026
michaelrj-google wrote:
Thanks for the explanation, the part I didn't understand was why anyone was using the `t` flag at all. Knowing that it has a proper meaning on Windows ([documentation for future reference](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170#:~:text=following%20characters%20can%20be%20appended%20to%20mode)) makes a lot more sense. In that case I have two suggestions:
1) `FileMode` should accept `t` as a flag, similarly to how we accept `e` as a flag despite it being Linux specific. Ignoring `t` on linux is fine, on Windows it tells the file to translate newlines from CR-LF to LF and back.
2) The parser should be fixed to properly reject modes that have invalid characters in the middle, such as `r?b`
If the programs are open source and accept contributions we can absolutely fix them. Adding a guard to use `rt` or `wt` on Windows should be a straightforward change and I would guess most maintainers would accept it. In this case it's probably not necessary, but it's something to keep in mind.
https://github.com/llvm/llvm-project/pull/236968
More information about the libc-commits
mailing list