Repository navigation
feat(libc): implement wide and unlocked stream I/O - #5816
adriadam10 merged 1 commit into
Conversation
Progress report (4469ea2 → 6509ec2)📈 System libraries: 88.7% (+0.02%, +7 implemented functions) ✅ 7 implemented
|
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the PR. Build and ctest pass here, and the new test fails to link without the change. One problem to fix:
getwc,getwcharandfgetwssit on top offgetwc(core/libs/prx/libc/src/StandardStreams.cpp:22), which reads a single byte, whilefputwc/putwc/putwcharwrite UTF-8 (core/libs/prx/libc/src/FormattingWide.cpp:335).putwc(u'é')followed bygetwcreturns0xC3, not0xE9, so the pair does not round-trip for anything >= 0x80. The tests only use ASCII, so they cannot see it. Either decode UTF-8 in the read path (and test a 2-byte and a 3-byte character withfgetws/getwc), or throw for bytes >= 0x80 and record the limit indocs/dev/debt/libc.md.fgetws(FormattingWide.cpp:380-388) returns the partial buffer whenfgetwcfails with an error mid-line, not only on EOF. FreeBSD'sfgetwsreturns NULL on error; please checkferrorafter the loop.
Rest looks fine: the unlocked variants reuse getc_unlocked/putc_unlocked, and the debt lines are in the right section.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
6970d3d to
6509ec2
Compare
|
Thank you for the review! Updated in the latest push:
|
adriadam10
left a comment
There was a problem hiding this comment.
Re-checked against the new head: fgetwc now decodes UTF-8, so putwc/getwc/fgetws round-trip é and € (new tests), and fgetws returns NULL on stream error. Build and ctest pass here and the new test still fails to link without the change; merging once the full build is green.
What
Implement 7 missing POSIX/FreeBSD standard stream I/O functions in libc:
fgetws(NID:F81hKe2k2tg): Read wide string from stream until newline or EOF, with buffer size and null pointer validation.getwc(NID:CosTELN5ETk): Read single wide character from stream.getwchar(NID:n2mWDsholo8): Read wide character from standard input (__stdinp).putwc(NID:UZJnC81pUCw): Write wide character to stream.putwchar(NID:aW9KhGC4cOo): Write wide character to standard output (__stdoutp).getchar_unlocked(NID:H0pVDvSuAVQ): Fast unlocked character input from standard input (__stdinp).putchar_unlocked(NID:v95AEAzqm+0): Fast unlocked character output to standard output (__stdoutp).Also adds comprehensive unit tests in
GuestStandardStreams.cppcovering wide string line reading, single/unlocked character I/O, error handling, EOF, and buffer bounds, and updates technical debt documentation indocs/dev/debt/libc.md.Tested
Windows 10, built with GCC 15 / Ninja.
Ran unit test suite via CTest:
guest_standard_streamspassed (100% tests passed)file_streams,guest_wide_formatting,guest_wide_strings,guest_wide_conversionpassedtools/check_conventions.pypassed with 0 findingsChecklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)