feat(libc): implement strsep and memccpy #1976

Closed
Pedroj-64 wants to merge 1 commit from upstream-pr/1976 into main
Pedroj-64 commented 2026-10-09 03:37:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pedroj-64 on 2026-10-09T03:37:29Z.


What

strsep and memccpy were not exported.

  • strsep follows BSD: it returns the token up to the first delimiter, overwrites the delimiter with NUL and advances the cursor past it, returns empty tokens, and sets the cursor to null after the last token. A null cursor returns null.

  • memccpy copies up to and including the first byte equal to (unsigned char)c, returns the address after it in the destination, and returns null after copying all n bytes when the byte is absent.

  • core/libs/prx/libc/src/StringExtensions.cpp: both functions.

  • guest_strings test: empty tokens, last token, null cursor, found and missing byte, a stop value above 255 and a zero count.

Tested

Linux (CachyOS), GCC 16.2.1, Release.

  • guest_strings passes.
  • tools/check_conventions.py --base upstream/main passes.

Not tested on Windows or macOS.

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:4795662619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1976). Originally posted by [Pedroj-64](https://github.com/Pedroj-64) on 2026-10-09T03:37:29Z. --- ### What `strsep` and `memccpy` were not exported. - `strsep` follows BSD: it returns the token up to the first delimiter, overwrites the delimiter with NUL and advances the cursor past it, returns empty tokens, and sets the cursor to null after the last token. A null cursor returns null. - `memccpy` copies up to and including the first byte equal to `(unsigned char)c`, returns the address after it in the destination, and returns null after copying all `n` bytes when the byte is absent. - `core/libs/prx/libc/src/StringExtensions.cpp`: both functions. - `guest_strings` test: empty tokens, last token, null cursor, found and missing byte, a stop value above 255 and a zero count. ### Tested Linux (CachyOS), GCC 16.2.1, Release. - `guest_strings` passes. - `tools/check_conventions.py --base upstream/main` passes. Not tested on Windows or macOS. ### 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
github-actions[bot] commented 2026-10-09 04:36:28 +00:00 (Migrated from github.com)

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


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#1848 core/libs/prx/libc/src/StringExtensions.cpp L75
#1972 core/libs/prx/libc/src/StringExtensions.cpp L75
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074351380 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1976#issuecomment-6074351380). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T04:36:28Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1848 | `core/libs/prx/libc/src/StringExtensions.cpp` [L75](https://github.com/boykopovar/AnyPS5/blob/6cc0503dacc9d9697d23001d4103780ad2e9acba/core/libs/prx/libc/src/StringExtensions.cpp#L75) | | | | #1972 | `core/libs/prx/libc/src/StringExtensions.cpp` [L75](https://github.com/boykopovar/AnyPS5/blob/6cc0503dacc9d9697d23001d4103780ad2e9acba/core/libs/prx/libc/src/StringExtensions.cpp#L75) | | |
MarcZX10 commented 2026-10-09 06:06:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:06:31Z.

Review: APPROVED


Reviewed the full diff against current main. strsep preserves empty fields and advances the cursor correctly; memccpy compares the stop value as an unsigned byte and returns the first byte after the copied delimiter. The added cases cover the key boundary behavior. I built and ran the exact head on Linux with GCC 12: guest_strings passed (1/1); conventions and diff checks pass. #1848 and #1972 add different functions in the same source file (#1972 depends on #1848), so there is no duplicate implementation. Note that open PR #2001 deletes GuestStrings.cpp; if that PR proceeds, it needs to preserve these and existing regression checks. Upstream Build/Conventions checks still have no results for this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5466326153 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1976#pullrequestreview-5466326153). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T06:06:31Z. **Review:** APPROVED --- Reviewed the full diff against current main. `strsep` preserves empty fields and advances the cursor correctly; `memccpy` compares the stop value as an unsigned byte and returns the first byte after the copied delimiter. The added cases cover the key boundary behavior. I built and ran the exact head on Linux with GCC 12: guest_strings passed (1/1); conventions and diff checks pass. #1848 and #1972 add different functions in the same source file (#1972 depends on #1848), so there is no duplicate implementation. Note that open PR #2001 deletes GuestStrings.cpp; if that PR proceeds, it needs to preserve these and existing regression checks. Upstream Build/Conventions checks still have no results for this head.
oneandonlydean commented 2026-10-09 08:55:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:55:46Z.


Closing: no title is shown to reach strsep or memccpy on main, and library functions go in when one does. Reopen with the title ID and the log line where it stops.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077720355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1976#issuecomment-6077720355). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T08:55:46Z. --- Closing: no title is shown to reach `strsep` or `memccpy` on main, and library functions go in when one does. Reopen with the title ID and the log line where it stops.
popcoder565 commented 2026-10-09 10:03:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:03:54Z.


First Windows run, since the description says it wasn't tested on Windows.

Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto main b7218b3c together with nine other small libc/libkernel PRs: #1975, #1977, #1859, #1685, #1676, #1675, #1641, #1656, #1807.

  • guest_strings passes.
  • Full ctest: 510/510 (one GPU test skipped for a device limit).

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078728406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1976#issuecomment-6078728406). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T10:03:54Z. --- First Windows run, since the description says it wasn't tested on Windows. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Merged onto `main` b7218b3c together with nine other small libc/libkernel PRs: #1975, #1977, #1859, #1685, #1676, #1675, #1641, #1656, #1807. - `guest_strings` passes. - Full ctest: 510/510 (one GPU test skipped for a device limit). _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_

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!1976
No description provided.