feat(libc): implement strsep #3192

Merged
reyani-dev merged 1 commit from upstream-pr/3192 into main 2026-10-11 06:05:37 +00:00
reyani-dev commented 2026-10-11 00:51:36 +00:00 (Migrated from github.com)

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


Resubmission of #2187, which was closed because no title was shown stopping on strsep. With execvp (#2827) merged, VLC (PPSA85300) now stops at strsep on main 06da1176, per @babyhuey's catalog run with sce_module/libc.prx unwrapped (comment):

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

cJWGxiQPmDQ is strsep. With this change the title moves on to nanf (DZU+K1wozGI), per the same run. strsep is still absent on current main, and no open PR implements it. The branch is rebased onto current main. Windows 11 (WinLibs GCC 15.2.0), Release: guest_strings passes 3/3, and check_conventions.py and pr_overlap.py --branch pass.


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:4815588282 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3192). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T00:51:36Z. --- Resubmission of #2187, which was closed because no title was shown stopping on `strsep`. With `execvp` (#2827) merged, VLC (PPSA85300) now stops at `strsep` on `main` 06da1176, per @babyhuey's catalog run with `sce_module/libc.prx` unwrapped ([comment](https://github.com/boykopovar/AnyPS5/pull/2187#issuecomment-6103870097)): ``` app.elf: symbol lookup error: app.elf: undefined symbol: cJWGxiQPmDQ ``` `cJWGxiQPmDQ` is `strsep`. With this change the title moves on to `nanf` (`DZU+K1wozGI`), per the same run. `strsep` is still absent on current `main`, and no open PR implements it. The branch is rebased onto current `main`. Windows 11 (WinLibs GCC 15.2.0), Release: `guest_strings` passes 3/3, and `check_conventions.py` and `pr_overlap.py --branch` pass. --- ### 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-11 00:51:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T00:51:58Z.


Progress report (06da117 → 0f480c6)

➖ System libraries: 85.96% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc strsep_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103933106 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3192#issuecomment-6103933106). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T00:51:58Z. --- <!-- progress-report --> ### Progress report (06da117 → 0f480c6) ➖ **System libraries**: 85.96% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `strsep_nid_postfix` | </details>
reyani-dev commented 2026-10-11 01:08:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T01:08:17Z.


Fork CI for this head merged onto current main (run 38099856726):

  • Windows: 759/759 passed.
  • Linux: 752/755 passed. The 3 failures are agc_unit_shadow, agc_driver_flat_apertures (timeout) and agc_driver_image_packed16_load, which fail identically in main's own push build (run 38098335801). This PR only touches libc, so they're unrelated.
  • Relinker jobs: green.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104052389 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3192#issuecomment-6104052389). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T01:08:17Z. --- Fork CI for this head merged onto current `main` ([run 38099856726](https://github.com/AchrafReyani/AnyPS5/actions/runs/38099856726)): - **Windows**: 759/759 passed. - **Linux**: 752/755 passed. The 3 failures are `agc_unit_shadow`, `agc_driver_flat_apertures` (timeout) and `agc_driver_image_packed16_load`, which fail identically in `main`'s own push build ([run 38098335801](https://github.com/boykopovar/AnyPS5/actions/runs/38098335801)). This PR only touches libc, so they're unrelated. - Relinker jobs: green.
babyhuey commented 2026-10-11 01:37:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T01:37:00Z.


Checked with #3190, #3191 and #3192 stacked on main d31b57a4 (all merge cleanly), catalog builds with sce_module/libc.prx unwrapped. Linux (Ubuntu 24.04, GCC 13) and Windows 11 (WinLibs GCC 15.2), Release: guest_math and guest_strings pass 5/5 (--repeat until-fail:5) on both, with no warnings in Math.cpp or StringExtensions.cpp.

VLC (PPSA85300) gets past strsep on both:

  • Linux: app.elf: symbol lookup error: app.elf: undefined symbol: DZU+K1wozGI (nanf)
  • Windows: FAIL: unresolved ELF import Wn6I3wVATUE (daemon) from libSceLibcInternal.prx

The Windows loader names a different first missing import; both are missing on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104257340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3192#issuecomment-6104257340). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-11T01:37:00Z. --- Checked with #3190, #3191 and #3192 stacked on `main` d31b57a4 (all merge cleanly), catalog builds with `sce_module/libc.prx` unwrapped. Linux (Ubuntu 24.04, GCC 13) and Windows 11 (WinLibs GCC 15.2), Release: `guest_math` and `guest_strings` pass 5/5 (`--repeat until-fail:5`) on both, with no warnings in `Math.cpp` or `StringExtensions.cpp`. VLC (PPSA85300) gets past `strsep` on both: - Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: DZU+K1wozGI` (`nanf`) - Windows: `FAIL: unresolved ELF import Wn6I3wVATUE (daemon) from libSceLibcInternal.prx` The Windows loader names a different first missing import; both are missing on `main`.
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!3192
No description provided.