fix(libc): count wide string precision in output characters #427

Merged
RomainROCH merged 1 commit from upstream-pr/427 into main 2026-10-04 04:50:54 +00:00
RomainROCH commented 2026-10-03 02:23:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RomainROCH on 2026-10-03T02:23:05Z.


What

Count the precision of narrow strings in wide formatting in the UTF-16 units produced, rather than UTF-8 input bytes. Preserve complete surrogate pairs when the remaining precision is too small.

For example, %.2s with two UTF-8 accented characters previously returned only the first character.

Tested

Source commit: 5211ba115bcbb4abdb7d7468f6126dd8f8abc10f, based on main at e006f64237e49d8ad4c054ef0c197a1d20fada50.

The full upstream Build workflow succeeded on Linux and Windows. It checked out merge commit 6ae9fbf3c0538042973b6823f8eb12a92e7ae29c; its tree f62127ee5c4ea8a2d16077d5977ced4b08e825f8 is identical to the source commit's tree.

Both platforms used Release configuration, Ninja and GCC/G++ 15.2.0, built the default and libs targets, and ran CTest with --repeat until-fail:3. The full CTest run includes the registered relinker tests.

Platform Passed tests Skipped tests Failed tests
Linux 156 6 0
Windows 133 29 0

Each platform registered 162 tests; the passed column excludes skipped tests. The focused guest_wide_formatting regression passed in all three repetitions on both platforms. The existing file_position test setup was retained when resolving the CMake conflict.

Skipped GPU/AGC execution tests

Linux: agc_driver_pixel_helper_lanes, agc_driver_read_first_lane, agc_driver_read_lane, agc_driver_scalar_bit_count, agc_driver_wave_uniform, agc_driver_write_lane.

Windows: agc_driver_cache_control, agc_driver_float16_misc, agc_driver_float16_rounding, agc_driver_fma_rounding, agc_driver_image_atomics, agc_driver_image_sample_lod_clamp, agc_driver_integer_dot, agc_driver_lds_atomics, agc_driver_mix_precision, agc_driver_pixel_helper_lanes, agc_driver_read_first_lane, agc_driver_read_lane, agc_driver_scalar_bit_count, agc_driver_scalar_relative_indexing, agc_driver_scalar_sopk_compare, agc_driver_sdwa_destination, agc_driver_shader_clock, agc_driver_vop1_control, agc_driver_vop3_aliases, agc_driver_vop3_compare_modifiers, agc_driver_vop3_integer, agc_driver_vop3_lerp, agc_driver_vop3_sad, agc_driver_vopc_compare, agc_driver_vopc_compare_f64, agc_driver_wave_id_in_workgroup, agc_driver_wave_sleep, agc_driver_wave_uniform, agc_driver_write_lane.

An isolated local check with GCC 16.1 could not link (__gxx_personality_v0), so it did not execute. The successful checks above are the full upstream workflow on the specified commit, including the wide-formatting regression.

Coverage includes ASCII, accented characters, zero precision, short strings, no precision, padding, and supplementary characters at precision boundaries. All fixtures are synthetic. No game or homebrew title was tested; these results do not establish game compatibility.

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; no silent stub added
  • No investigation notes, reports or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4723446285 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/427). Originally posted by [RomainROCH](https://github.com/RomainROCH) on 2026-10-03T02:23:05Z. --- ### What Count the precision of narrow strings in wide formatting in the UTF-16 units produced, rather than UTF-8 input bytes. Preserve complete surrogate pairs when the remaining precision is too small. For example, `%.2s` with two UTF-8 accented characters previously returned only the first character. ### Tested Source commit: `5211ba115bcbb4abdb7d7468f6126dd8f8abc10f`, based on `main` at `e006f64237e49d8ad4c054ef0c197a1d20fada50`. The full [upstream Build workflow](https://github.com/boykopovar/AnyPS5/actions/runs/37171465855) succeeded on Linux and Windows. It checked out merge commit `6ae9fbf3c0538042973b6823f8eb12a92e7ae29c`; its tree `f62127ee5c4ea8a2d16077d5977ced4b08e825f8` is identical to the source commit's tree. Both platforms used Release configuration, Ninja and GCC/G++ 15.2.0, built the default and `libs` targets, and ran CTest with `--repeat until-fail:3`. The full CTest run includes the registered relinker tests. | Platform | Passed tests | Skipped tests | Failed tests | | --- | ---: | ---: | ---: | | Linux | 156 | 6 | 0 | | Windows | 133 | 29 | 0 | Each platform registered 162 tests; the passed column excludes skipped tests. The focused `guest_wide_formatting` regression passed in all three repetitions on both platforms. The existing `file_position` test setup was retained when resolving the CMake conflict. <details> <summary>Skipped GPU/AGC execution tests</summary> Linux: `agc_driver_pixel_helper_lanes`, `agc_driver_read_first_lane`, `agc_driver_read_lane`, `agc_driver_scalar_bit_count`, `agc_driver_wave_uniform`, `agc_driver_write_lane`. Windows: `agc_driver_cache_control`, `agc_driver_float16_misc`, `agc_driver_float16_rounding`, `agc_driver_fma_rounding`, `agc_driver_image_atomics`, `agc_driver_image_sample_lod_clamp`, `agc_driver_integer_dot`, `agc_driver_lds_atomics`, `agc_driver_mix_precision`, `agc_driver_pixel_helper_lanes`, `agc_driver_read_first_lane`, `agc_driver_read_lane`, `agc_driver_scalar_bit_count`, `agc_driver_scalar_relative_indexing`, `agc_driver_scalar_sopk_compare`, `agc_driver_sdwa_destination`, `agc_driver_shader_clock`, `agc_driver_vop1_control`, `agc_driver_vop3_aliases`, `agc_driver_vop3_compare_modifiers`, `agc_driver_vop3_integer`, `agc_driver_vop3_lerp`, `agc_driver_vop3_sad`, `agc_driver_vopc_compare`, `agc_driver_vopc_compare_f64`, `agc_driver_wave_id_in_workgroup`, `agc_driver_wave_sleep`, `agc_driver_wave_uniform`, `agc_driver_write_lane`. </details> An isolated local check with GCC 16.1 could not link (`__gxx_personality_v0`), so it did not execute. The successful checks above are the full upstream workflow on the specified commit, including the wide-formatting regression. Coverage includes ASCII, accented characters, zero precision, short strings, no precision, padding, and supplementary characters at precision boundaries. All fixtures are synthetic. No game or homebrew title was tested; these results do not establish game compatibility. ### 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 - [x] Unimplemented paths throw; no silent stub added - [x] No investigation notes, reports or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
oneandonlydean commented 2026-10-04 01:40:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T01:40:03Z.


This now conflicts with main after #428 touched the same libc test setup; could you rebase? The change itself looks right to me (C11 counts precision in output units).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5975468670 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/427#issuecomment-5975468670). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T01:40:03Z. --- This now conflicts with main after #428 touched the same libc test setup; could you rebase? The change itself looks right to me (C11 counts precision in output units).
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!427
No description provided.