feat(libc): implement stpcpy #1812

Merged
DariusHQ merged 1 commit from upstream-pr/1812 into main 2026-10-09 22:08:34 +00:00
DariusHQ commented 2026-10-08 20:04:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DariusHQ on 2026-10-08T20:04:10Z.


What

stpcpy (ZSnX-xZBGCg) is absent from the libc exports. PICO-8 for PS5 (PPSA99808) imports it from libSceLibcInternal, one of the absent imports that #1578 lists for that title. Part of #1578

POSIX.1-2008 defines stpcpy as strcpy that returns a pointer to the terminating null byte of the copy instead of to its start. The export copies the string with its terminator and returns destination + strlen(source)

The NID matches the built libc.prx:

$ python3 -c "import sys; sys.path.insert(0,'tools'); from nid_names import compute_nid; print(compute_nid('stpcpy'))"
ZSnX-xZBGCg

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with BUILD_TESTING=ON: ctest 477/477 passed. guest_strings checks the returned pointer over two chained copies, that no byte past the terminator is written, and an empty source. The build and tests ran on b858fdc4; the branch was then rebased onto 4b6ab6bb, whose new commits touch only shaders and CI. Not tested on Linux. No title run: PPSA99808 still has other absent imports.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792164011 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1812). Originally posted by [DariusHQ](https://github.com/DariusHQ) on 2026-10-08T20:04:10Z. --- ### What `stpcpy` (`ZSnX-xZBGCg`) is absent from the libc exports. PICO-8 for PS5 (PPSA99808) imports it from `libSceLibcInternal`, one of the absent imports that #1578 lists for that title. Part of #1578 POSIX.1-2008 defines `stpcpy` as `strcpy` that returns a pointer to the terminating null byte of the copy instead of to its start. The export copies the string with its terminator and returns `destination + strlen(source)` The NID matches the built `libc.prx`: ``` $ python3 -c "import sys; sys.path.insert(0,'tools'); from nid_names import compute_nid; print(compute_nid('stpcpy'))" ZSnX-xZBGCg ``` ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with `BUILD_TESTING=ON`: `ctest` 477/477 passed. `guest_strings` checks the returned pointer over two chained copies, that no byte past the terminator is written, and an empty source. The build and tests ran on `b858fdc4`; the branch was then rebased onto `4b6ab6bb`, whose new commits touch only shaders and CI. Not tested on Linux. No title run: PPSA99808 still has other absent imports. ### 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
adriadam10 commented 2026-10-09 22:08:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:08:31Z.


Checked on Linux (main + this PR): build and ctest 523/523, guest_strings passes and fails to link without the change. NID ZSnX-xZBGCg matches stpcpy; semantics match POSIX.1-2008. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090069359 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1812#issuecomment-6090069359). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:08:31Z. --- Checked on Linux (main + this PR): build and ctest 523/523, `guest_strings` passes and fails to link without the change. NID `ZSnX-xZBGCg` matches `stpcpy`; semantics match POSIX.1-2008. Merging once CI is green.
github-actions[bot] commented 2026-10-09 22:10:58 +00:00 (Migrated from github.com)

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


Progress report (364a56b → e411282)

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

✅ 1 implemented
Library Name
libc stpcpy_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090099363 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1812#issuecomment-6090099363). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T22:10:58Z. --- <!-- progress-report --> ### Progress report (364a56b → e411282) ➖ **System libraries**: 84.76% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `stpcpy_nid_postfix` | </details>
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!1812
No description provided.