feat(libc): implement strsep #2187

Closed
reyani-dev wants to merge 1 commit from upstream-pr/2187 into main
reyani-dev commented 2026-10-09 11:07:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:07:16Z.


What

Exports strsep with FreeBSD's semantics (lib/libc/string/strsep.c):

  • It returns the token at *stringp, ending at the first delimiter.
  • The delimiter is overwritten with NUL, and *stringp advances past it.
  • Empty fields are returned, unlike strtok.
  • When no delimiter is left, *stringp becomes NULL; with *stringp == NULL it returns NULL.

Title: PPSA99169 RetroArch imports it from libSceLibcInternal (resolved through libc.prx), per the #1578 audit. I haven't run the title.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, -DBUILD_TESTING=ON:

  • New checks in guest_string_tests, next to the strtok cases:
    • a leading empty field and an empty middle field (",a,,b;c" with ",;");
    • the cursor after each call and NULL after the last token;
    • NULL once exhausted;
    • an empty delimiter set returns the whole string;
    • an empty string returns "" and then NULL.
  • Mutation check: delegating to strtok_r, which skips empty fields, makes guest_strings fail.
  • cmake --build build --target libs: the patched libc.prx exports cJWGxiQPmDQ.
  • tools/check_conventions.py passes, and tools/pr_overlap.py --branch reports no overlap. The function is placed away from the lines #1812, #1848 and #1972 change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799578827 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2187). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:07:16Z. --- ### What Exports `strsep` with FreeBSD's semantics (`lib/libc/string/strsep.c`): - It returns the token at `*stringp`, ending at the first delimiter. - The delimiter is overwritten with NUL, and `*stringp` advances past it. - Empty fields are returned, unlike `strtok`. - When no delimiter is left, `*stringp` becomes NULL; with `*stringp == NULL` it returns NULL. Title: PPSA99169 RetroArch imports it from `libSceLibcInternal` (resolved through `libc.prx`), per the #1578 audit. I haven't run the title. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Release, `-DBUILD_TESTING=ON`: - New checks in `guest_string_tests`, next to the `strtok` cases: - a leading empty field and an empty middle field (`",a,,b;c"` with `",;"`); - the cursor after each call and NULL after the last token; - NULL once exhausted; - an empty delimiter set returns the whole string; - an empty string returns `""` and then NULL. - Mutation check: delegating to `strtok_r`, which skips empty fields, makes `guest_strings` fail. - `cmake --build build --target libs`: the patched `libc.prx` exports `cJWGxiQPmDQ`. - `tools/check_conventions.py` passes, and `tools/pr_overlap.py --branch` reports no overlap. The function is placed away from the lines #1812, #1848 and #1972 change. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-09 11:07:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T11:07:39Z.


Progress report (d70b899 → 804674f)

📈 System libraries: 84.7% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc strsep_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079658771 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2187#issuecomment-6079658771). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T11:07:39Z. --- <!-- progress-report --> ### Progress report (d70b899 → 804674f) 📈 **System libraries**: 84.7% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `strsep_nid_postfix` | </details>
reyani-dev commented 2026-10-09 11:39:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:39:27Z.


Full Linux and Windows builds and tests for this head (804674f2), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 516/516 passed
windows success; full build, ctest: 507/507 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37921802565

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080117538 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2187#issuecomment-6080117538). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:39:27Z. --- Full Linux and Windows builds and tests for this head (`804674f2`), using the project's Build workflow. I can't start the upstream manual run, so I ran the same `build.yml` in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current `main` (`d70b8998`): | Job | Result | |---|---| | [linux](https://github.com/AchrafReyani/AnyPS5/actions/runs/37921802565/job/113791318656) | success; full build, `ctest`: 516/516 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/37921802565/job/113791318514) | success; full build, `ctest`: 507/507 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37921802565
oneandonlydean commented 2026-10-09 20:09:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:09:54Z.


Same as #2167, for strsep.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088440927 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2187#issuecomment-6088440927). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:09:54Z. --- Same as #2167, for `strsep`.
babyhuey commented 2026-10-11 00:43:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T00:43:31Z.


@AchrafReyani strsep is now a title's next stop on main. With execvp (#2827) merged, VLC (PPSA85300) on main 06da1176 reports this on Linux (catalog build, sce_module/libc.prx unwrapped as #2605 requires):

app.elf: symbol lookup error: app.elf: undefined symbol: cJWGxiQPmDQ

This head (804674f2) merges cleanly onto 06da1176, guest_strings passes 5/5 (--repeat until-fail:5), and VLC then stops at nanf (DZU+K1wozGI).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103870097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2187#issuecomment-6103870097). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-11T00:43:31Z. --- @AchrafReyani `strsep` is now a title's next stop on `main`. With `execvp` (#2827) merged, VLC (PPSA85300) on `main` 06da1176 reports this on Linux (catalog build, `sce_module/libc.prx` unwrapped as #2605 requires): `app.elf: symbol lookup error: app.elf: undefined symbol: cJWGxiQPmDQ` This head (804674f2) merges cleanly onto 06da1176, `guest_strings` passes 5/5 (`--repeat until-fail:5`), and VLC then stops at `nanf` (`DZU+K1wozGI`).
reyani-dev commented 2026-10-11 00:51:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T00:51:38Z.


Thanks @babyhuey, resubmitted as #3192, rebased onto current main with your stop.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103930707 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2187#issuecomment-6103930707). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T00:51:38Z. --- Thanks @babyhuey, resubmitted as #3192, rebased onto current `main` with your stop.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2187
No description provided.