Skip to content

fix(libc): preserve zero in alternate wide octal formatting - #8440

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
mazen320:fix/printf-alternate-octal-zero
Oct 20, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
mazen320:fix/printf-alternate-octal-zero

Conversation

@mazen320

Copy link
Copy Markdown
Contributor

What

Wide formatting now preserves the zero digit for alternate-form octal output with precision zero: swprintf(..., u"%#.0o", 0u) produces 0 instead of an empty string. The shared wide formatter applies the same normalization already present in the narrow formatter, after narrowing h/hh arguments and before host formatting.

The reference is FreeBSD 11.4 vfwprintf.c, number conversion, which retains zero for alternate octal even when precision is zero. This is source-based compatibility work; it was not measured on a PS5.

Related #5293 and #5303 address additional conversions. This change covers the residual alternate-octal case, does not close the broader issue, and merges cleanly with the current #5303 head in a local merge-tree check. That combination was not executed.

Tested

Windows, WinLibs GCC 15.2.0 UCRT, Release, based on main 02b5a8e55.

  • With only the regression added to main, guest_wide_formatting aborts at swprintf alternate octal zero.
  • After the two-line implementation change, guest_wide_formatting, guest_formatting, all three guest_standard_streams modes and file_streams pass (6/6).
  • New cases cover swprintf, vswprintf, snwprintf_s, empty/zero precision, field width, alignment, zero padding, dynamic and positional precision, h/hh narrowing, long long, bounded output, and unaffected hexadecimal/unflagged/nonzero cases.
  • python tools/check_conventions.py --base upstream/main and git diff --check pass. Linux and a console/title run were not performed.
  • tools/pr_overlap.py reported only an uncomparable shared test file in test: organize library tests and label CTest suites #6044; manual inspection shows it is a pure rename to tests/runtime/GuestWideFormatting.cpp (zero additions/deletions), with no duplicate logic.

Checklist

  • Based on current main; no other open PR implements the same functions (no duplicate alternate-octal fix found; related fix(libc): follow measured wide printf behavior #5303 changes other cases in the shared wide formatter)
  • 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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestWideFormatting.cpp

@github-actions github-actions Bot added the libc label Oct 20, 2026
@oneandonlydean
oneandonlydean merged commit f69bb8e into boykopovar:main Oct 20, 2026
18 checks passed
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.

2 participants