Skip to content

feat(libc): implement collate<wchar_t>::_Getcat - #3990

Closed
Sam-mon7 wants to merge 1 commit into
boykopovar:mainfrom
Sam-mon7:feat/libc-collate-wchar
Closed

Sam-mon7 wants to merge 1 commit into
boykopovar:mainfrom
Sam-mon7:feat/libc-collate-wchar

Conversation

@Sam-mon7

Copy link
Copy Markdown
Contributor

What

Implements std::collate<wchar_t>::_Getcat (libc), which was a NotImplemented stub.

  • The C-locale char facet from a546bbe (collate<char>::_Getcat) is generalised over the character type: GuestLocale::BasicString<TChar> and BasicCollateVtable<TChar>, with String/CollateVtable kept as aliases. do_compare, do_transform and do_hash are templates; the char behaviour is unchanged and the existing guest_collate checks still pass.
  • The wide facet uses 16-bit guest wchar_t (char16_t, as elsewhere in libc):
    • do_compare orders units as unsigned values, matching libc's wcscoll in the C locale.
    • do_hash is the FNV-1a of the range's bytes, which is what Dinkumware's _Hash_seq((const unsigned char*)first, (last - first) * sizeof(_Elem)) gives for both facets; the char facet already matches it.
    • do_transform builds a basic_string<wchar_t> with the same 0x28-byte layout (7 inline characters) and the same sizing as the char facet; it throws on embedded nulls and at the 4096-byte large-allocation threshold (2047 characters), as the char facet does at 4095.
  • The stub's signature is corrected to match the char export: returns size_t (the category, 1) and takes const locale* (const Implementation* const*).
  • The wide behaviour was not compared with the console; this is recorded in TechnicalDebt next to the existing collate<char> entry.

Tested

Windows 11, WinLibs GCC 15.2.0 ucrt r7, Release, full build + ctest -j 8: 836/837 passed. The one failure, guest_sce_net, times out on a host DNS lookup in my environment and does not touch libc locale code. guest_collate now also covers the wide facet (unsigned ordering above U+00FF, byte-wise hash, inline/heap transform boundary at 7/8 characters, the 2046/2047 size limit, invalid ranges, reference counting and deletion). tools/check_conventions.py passes.

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

@MarcZX10

Copy link
Copy Markdown
Contributor

Independent Linux check on PR head 8246a132: configured Release with GCC 12.2.0 and BUILD_TESTING=ON, built guest_collate_tests, then ran ctest --test-dir /tmp/AnyPS5-pr-3990-build -R "^guest_collate$" --output-on-failure. Result: 1/1 passed (0.04 s). This checks the registered test on Linux; it does not validate the Windows-specific layout behavior.

@Sam-mon7

Copy link
Copy Markdown
Contributor Author

Independent Linux check on PR head 8246a132: configured Release with GCC 12.2.0 and BUILD_TESTING=ON, built guest_collate_tests, then ran ctest --test-dir /tmp/AnyPS5-pr-3990-build -R "^guest_collate$" --output-on-failure. Result: 1/1 passed (0.04 s). This checks the registered test on Linux; it does not validate the Windows-specific layout behavior.

Thanks for checking on Linux!

@Kikoarl

Kikoarl commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Tested on Linux (CachyOS x86_64, GCC):

  • Clean build on Linux with zero warnings or errors.
  • guest_collate passes 100% (covering the new 16-bit wchar_t wide facet, unsigned ordering above U+00FF, FNV-1a byte hash, and the inline/heap transform boundary).
  • tools/check_conventions.py passes clean.

Confirms clean behavior on Linux beyond the Windows 11 MinGW environment. LGTM!

@github-actions github-actions Bot added libc docs needs rebase Conflicts with main, rebase needed labels Oct 11, 2026
@Sam-mon7
Sam-mon7 force-pushed the feat/libc-collate-wchar branch from 8246a13 to 0a6ae52 Compare October 11, 2026 21:50
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: same as #2333 and #1982. No title is shown to stop at collate<wchar_t>::_Getcat on main, and the wide facet hasn't been compared with the console. Reopen with the title ID and the log line when one does.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants