Skip to content

feat(libc): implement strsep and memccpy - #1976

Closed
Pedroj-64 wants to merge 1 commit into
boykopovar:mainfrom
Pedroj-64:feat/libc-strsep-memccpy
Closed

Pedroj-64 wants to merge 1 commit into
boykopovar:mainfrom
Pedroj-64:feat/libc-strsep-memccpy

Conversation

@Pedroj-64

@Pedroj-64 Pedroj-64 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

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 b7218b3 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants