feat(libScePosixForWebKit): implement fnmatch #3545
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3545"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T12:56:33Z.
What
Exports
fnmatch(60q1rziOzzQ) from libScePosixForWebKit, ported from FreeBSD 11lib/libc/gen/fnmatch.cfor the C locale:?,*with backtracking, bracket expressions with!/^negation and ranges, backslash escapes, and the flagsFNM_NOESCAPE,FNM_PATHNAME,FNM_PERIOD,FNM_LEADING_DIRandFNM_CASEFOLDwith FreeBSD's values. A malformed bracket matches[literally, as FreeBSD does. Each byte is one character,FNM_CASEFOLDfolds ASCII letters and ranges compare byte values, and[:class:]names are plain bracket characters, as in FreeBSD 11 through 14; multibyte characters and locale collation are not modelled, which TechnicalDebt records. A null pattern or string throws.Cloud Play (PPSA99600) imports it from libScePosixForWebKit and stops at it on
maina11c8f7f(catalog build,eboot.binandsce_module/libc.prxunwrapped as #2605 requires; tracked in #1578):app.elf: symbol lookup error: app.elf: undefined symbol: 60q1rziOzzQFAIL: unresolved ELF import 60q1rziOzzQ (fnmatch) from libScePosixForWebKit.prxapp.elf: symbol lookup error: app.elf: undefined symbol: H1bArJPagV0(getservbyname)FAIL: unresolved ELF import H1bArJPagV0 (getservbyname) from libScePosixForWebKit.prxTested
Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: the new
guest_fnmatchpasses 5/5 (--repeat until-fail:5) on both, with no warnings in the changed files. Its 50 cases cover every flag,[[:digit:]]-style class syntax, ranges, negation, escapes, leading periods,FNM_PATHNAMEslashes and backtracking; each expected result comes from FreeBSD 11's ownfnmatch.ccompiled on Linux with the C-locale collation path. It also checks that a null pattern throws.check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T12:56:57Z.
Progress report (
a11c8f7→81e3e34)📈 System libraries: 85.82% (+0.01%, +1 implemented functions)
✅ 1 implemented
fnmatch_nid_postfixImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:15:52Z.
I noticed bracket expressions currently handle individual bytes and ranges, but not POSIX named character classes. For example,
[[:digit:]]is parsed as a literal[plus a trailing], so it won’t match7as FreeBSDfnmatchdoes in the C locale. Could you add the C-locale classes (at least a regression for[[:digit:]]) or make unsupported class syntax fail explicitly, so this doesn’t silently return a false match?Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T13:32:25Z.
@MarcZX100 thanks for checking. FreeBSD 11's
fnmatch.c, which this follows, has no[:class:]handling inrangematch: it reads[[:digit:]]as the set[,:,d,i,g,tfollowed by a literal]. stable/12, stable/13 and releng/14.1 are the same; class support only shows up on FreeBSDmain. Built as an oracle, FreeBSD 11's own code returnsFNM_NOMATCHfor[[:digit:]]against7and a match againstd], and so does this port.Since the PS5 libc follows FreeBSD 11, I kept that behaviour and pinned it:
81e3e346adds those cases (plus:]anda[[:alpha:]]againstab) toguest_fnmatchand says it in the TechnicalDebt line.guest_fnmatchpasses 5/5 on Linux and Windows.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:45:06Z.
Thanks for checking FreeBSD 11 directly and adding regression cases. My earlier assumption about POSIX named character classes was incorrect: the PS5 follows the older implementation, which parses those bytes literally. Your oracle results and tests resolve my concern.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T17:28:11Z.
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.
main)docs/dev/TechnicalDebt.mdL361Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:37:38Z.
Checked the port against FreeBSD 11
fnmatch.c(C-locale path) with 30M random pattern/string/flag combinations: no differences.guest_fnmatchpasses and does not link without the change; ctest for libs and libScePosixForWebKit is green. The NID resolves tofnmatchand no other library exports it. Merging.