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

Closed
Sam-mon7 wants to merge 1 commit from upstream-pr/3990 into main
Sam-mon7 commented 2026-10-11 20:44:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-11T20:44:25Z.


What

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

  • The C-locale char facet from a546bbef9 (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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4822211314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3990). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-11T20:44:25Z. --- ### What Implements `std::collate<wchar_t>::_Getcat` (libc), which was a `NotImplemented` stub. - The C-locale `char` facet from a546bbef9 (`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 - [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
MarcZX10 commented 2026-10-11 21:03:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T21:03:17Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113724970 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3990#issuecomment-6113724970). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T21:03:17Z. --- 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 commented 2026-10-11 21:13:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-11T21:13:59Z.


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!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113823818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3990#issuecomment-6113823818). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-11T21:13:59Z. --- > 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 commented 2026-10-11 21:21:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-11T21:21:09Z.


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!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113899407 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3990#issuecomment-6113899407). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-11T21:21:09Z. --- 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!
oneandonlydean commented 2026-10-12 00:00:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T00:00:35Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115364061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3990#issuecomment-6115364061). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T00:00:35Z. --- 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.

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