Repository navigation
Wave A: Q4 BAD-5 fixes + shared parser unsigned path - #1520
Merged
Merged
Conversation
OptionType gains UInt/OptionalUInt for options whose GNU parser is xstrtoumax. The numeric parse stays signed-first: in-range values (including negatives) store as int64_t, and only a positive out-of-range value stores exactly as uint64_t in the widened OptionValue variant. Int/OptionalInt options are untouched, so signed/bounded oracles (numfmt --padding, ptx -w) keep rejecting the (INT64_MAX, UINT64_MAX] band. get/get_all bridge the widths: signed reads of an unsigned store saturate, unsigned reads widen a non-negative signed store. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
…ed path (Refs #1519) locate -l (locate.c:1677), numfmt --header (numfmt.c:1558), uniq -f/-s/-w/-NUM (uniq.c size_opt) and expand/unexpand -NUM switch to UINT_TYPE/OPTIONAL_UINT_TYPE. Consumer negative diagnostics keep their shape because negatives still arrive in the signed store; locate reads the limit back as uint64_t, expand/unexpand render either store back to the decimal tab-stop string. Regression tests pin the band acceptance, the above-uint64 rejection, the signed option rejection, and the preserved negative messages. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
copy.c renders every filename in diagnostics and prompts through
quoteaf (shell_escape_always_quoting_style); mv embedded raw operand
bytes inside hand-written '...' quotes, so a name containing 0x01
reached the terminal raw (GNU 9.4 probe: mv: cannot stat
'x'$'\001''y'). utils gains gnu_quotearg::shell_escape_quote_always
(the always form of the existing shell_escape port, verified
byte-for-byte against GNU 9.4 mv on a 38-case battery) and every mv
diagnostic, prompt, and verbose rendering routes through it.
Ordinary names render exactly as before ('name').
Note: formatted by hand to the surrounding style; the local
clang-format is 23.1.3, not the project's pinned version, so
scripts/format was not run.
parse_chunk/parse_n_units (split.c:1317-1345) accept LONGINT_OVERFLOW and clamp to INTMAX_MAX; split's int64 from_chars parse rejected the whole (INT64_MAX, UINT64_MAX] band for -n, and -l/-b rejected it too. A scan_intmax helper reproduces the xstrtoimax scan (leading whitespace, optional sign, clamped accumulation); -n is rebuilt on it (whitespace before the l// r/ prefixes, k/N selection only for a clean non-overflowed head ending at '/', an overflowed k/N head dies with the whole argument quoted), -l and the -NUM form (now UINT_TYPE, Refs #1519) clamp through parse_positive_units, and parse_size clamps the mantissa and saturates the suffix multiply. The round-robin distributor no longer allocates one bucket per chunk: storage is capped at the record count and the remaining chunks are written empty, so a clamped N cannot exhaust memory before the first record lands. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
…342) fold opened operands with std::ifstream(narrow-string): the ctor decodes through the ANSI code page, so a name carrying non-ASCII bytes (the 0xFF case) was mangled before the open and the file was not found. The sanctioned boundary is file_io::open_binary_file (make_api_path_operand's wide path), as cat already uses. Swapped every binary argv-operand reader of the same shape: fold, csplit, expand, unexpand, fmt, du --exclude-from, less, the pager's load_seekable_document/line_at, ldd, column, more, strings, env --file, shuf --random-source. Text-mode readers (dircolors, hexdump -f, hostname -F) are the same ctor class but forcing binary would change their CRLF handling; they are listed as residuals in the lane report instead. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
'shred -' gated stdout on FILE_TYPE_DISK only, rejecting character devices and unknown types with 'invalid file type'. GNU do_wipefd (shred.c:816-853) rejects only (S_ISCHR && isatty) || S_ISFIFO || S_ISSOCK, so the gate is now that reject list: FILE_TYPE_PIPE, or FILE_TYPE_CHAR with a console attached. A target that reports no size (NUL) now reads size 0 — the size local was previously read uninitialized when GetFileSizeEx failed — and succeeds with no passes unless -s gives an explicit size. Tests spawn shred by hand with stdout bound to a regular file and to NUL (the Pipeline harness always pipes stdout, which remains the rejected shape and is pinned as such). Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
The original closure cited coreutils 8.32 output; the recheck discharges it: 8.32 printf.c parses %a arguments with vstrtold and forces the L length modifier exactly like 9.4 (printf.c:356 and 665-673 vs 427-455), so the form is the C library's %La in both — not version-relative. glibc %La leads with the significand's top nibble and prints exponent exp-3 (1.5 -> 0xcp-3); the renderer normalized to a leading 1 in newlib style (0x1.8p+0) and its subnormal arm was dead (subnormals arrive at exp == -16382, never below). The branch now works on the raw 64-bit significand: nibble-aligned digits for normals and subnormals alike, half-even rounding at the requested precision, and glibc's carry-out rule (digit 1, exponent +4). Validated pre-port against /usr/bin/printf on a 4,480-case battery of exact significand/exponent pairs (randomized normals, subnormals, tie patterns; all match). Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
) The missing-destination/extra-operand diagnostics inside parse_arguments (~line 493) precede the helper's original placement next to api_operand_w; MSVC reported C3861 in the first CI run. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
The quoteaf rework moves the quote characters out of mv's prompt and verbose literals into the quoting helper, so nine punctuation fragments change their legacy extraction keys (missing: 'removed ', ' (backup: ', ')', ' <-> '; extra: 'mv: overwrite '', 'mv: replace '', '', overriding mode 0444 (r--r--r--)? ', 'mv: not replacing '', '' <-> ''). No translatable prose changes and no assembled message changes for ordinary names. Recorded via check_i18n_drift.py --update-baseline, the gate's sanctioned path for deliberate growth; the zh-CN catalog sync in unixwin/winuxcmd-i18n (add the four new keys, drop the five stale ones, VERSION bump) is a follow-up for the captain to route.
…lips (Refs #471 #1519 #374) Product (gnu_float80 normalize): ERANGE was raised for EVERY subnormal parse result, so printf failed (exit 1) on exactly representable subnormals such as 0x1p-16445, where glibc strtold converts silently and coreutils printf exits 0 (both probed). The flag now follows the bits: range_err is set only when the subnormal shift actually drops nonzero bits (round or sticky). Inexact subnormals (1e-4935) keep ERANGE and the exit-1 face; a new pin covers each side. Pins (expectations transcribed wrong by hand; product output was already GNU-shaped in each case): - printf 0.1: fraction is 14 c nibbles + d (the value the 4,480-case model battery verified), not 12 + d. - printf %A: glibc uppercases the exponent marker too (0XCP-3). - numfmt header-above-uint64 and padding-band: GNU numfmt exits 1 on invalid numbers (probed), not 2. mv same-file pin: stream the actual stderr into the assertion message - the first run shows exit 1 with no raw control byte but not the expected same-file text, and the harness does not dump stderr, so the next run carries the evidence needed to locate the divergence. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
…efs #374) The repo's EXPECT_TRUE macro does not return a streamable assertion (MSVC C2143/C2059 at the << chain). The same-file diagnostic now prints the captured stderr with std::fprintf ahead of the unchanged assertion. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
CI evidence from the last run: mv answered 'cannot stat ''$'\001'' for the file TempDir::write created - the quoteaf rendering is correct, so the divergence is in file creation, cwd resolution, or the product stat, and the harness dumps nothing. The pin now asserts the file exists under its wide spelling (catching a silent write_all no-op or a narrow-name conversion mismatch), and a twin pin drives the same self-move through an absolute wide-spelled operand created via write_all directly, so one CI run separates the three candidate layers. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
CI localization verdict: a file whose ENTIRE name is one control character cannot be created on the CI host through either harness path (TempDir::write's narrow name and a direct write_all on the wide path both land nothing std::filesystem::exists can find; write_all swallows the CreateFileW error). That is a host environment limit, not the quoteaf rendering under test - mv's cannot-stat answer already rendered the name byte-exact. The pins now use 'a<0x01>b', whose GNU same-file rendering was re-probed: 'a'$'\001''b' on both sides. The creation assert and stderr diagnostics stay as guards. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
Two more CI facts folded in: the embedded-name attempt failed the same way (and exposed that the C++ literal a\x01b is a + ESC - \x consumes following hex digits). No control-char filename has been creatable on this host through any harness path so far. The same-file pins now use a'b, whose quoteaf rendering is the double-quote restyle (GNU-probed: "a'b" and "a'b" are the same file) that the old hand quoting rendered broken as 'a'b' - still a discriminating quoteaf pin. The absolute twin carries a temporary CreateFileW probe (DOS vs extended spelling + GetLastError) to settle the creation question from evidence; it comes out once read. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
…Refs #374) Probe evidence (previous head's CI log): CreateFileW on a control-char filename fails with ERROR_INVALID_NAME (123) on both the DOS and the extended spelling - the host's Win32 layer rejects such names outright, so the probe comes out and the fact is recorded in the twin's comment and the lane report. The absolute twin's expectation was also wrong in a way the relative pin masked: quoteaf quotes the operand as given, so an absolute path renders as one double-quoted string per side and the bare-name substring cannot appear; the pin now anchors on the shared tail. The relative a'b pin passed in the same run. Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
The tail anchor still missed while the relative pin passes, so the absolute-operand message differs from the model somewhere upstream of the tail; print it on the failure path (kept - it only fires when the assertion would fail anyway). Note: formatted by hand to the surrounding style; the local clang-format is 23.1.3, not the project's pinned version, so scripts/format was not run.
The dumped stderr shows the product rendering the absolute path
in the '\'' form ('...\a'\''b'), not the "..." restyle - and
GNU quotearg makes the same choice for backslash-bearing names
(probed with mv on 'a\b'\''c'): the restyle only applies when no
character stays special inside double quotes. Product correct;
pin anchored on the true tail.
Note: formatted by hand to the surrounding style; the local
clang-format is 23.1.3, not the project's pinned version, so
scripts/format was not run.
This was referenced Nov 4, 2026
caomengxuan666
marked this pull request as ready for review
November 4, 2026 08:48
This was referenced Nov 4, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wave A lane: Q4 BAD-5 reopens + the #1519 parser gate. All six items landed; full per-issue evidence (GNU file:line, probes, residuals) is in the lane report for the captain.
Refs #289 #342 #374 #471 #917 #1519
#1519 — shared parser unsigned path. Opt-in per-option signedness mirroring GNU's per-callsite xstrtoimax/xstrtoumax choice (probed: the band is an error for numfmt --padding and ptx -w, accepted for locate -l / numfmt --header / uniq counts, so a universal fallback would regress the bounded family). OptionType gains UInt/OptionalUInt; OptionValue gains a uint64_t alternative with signed-first storage (in-range values incl. negatives stay int64_t, keeping every negative diagnostic byte-identical) and saturating get/get_all bridges. Migrated: locate -l, numfmt --header, uniq -f/-s/-w/-NUM, expand -NUM, unexpand -NUM, split -NUM. Above UINT64_MAX still errors (GNU numfmt/locate shape).
#289 — split. -n parsing rebuilt on one clamped xstrtoimax scan: whitespace skipped before the l//r/ prefixes, K/N selected only by a clean head ending at '/', overflowed K/N head dies quoting the whole argument, -l and -NUM clamp instead of erroring; -b mantissa clamp + saturating multiply; round-robin storage capped at min(N, records) with remaining chunks written empty (was: vector sized by a clamped N). Pins include '5K' -> '5K', 1/0 -> '0', r/5 on 2 records -> 5 files.
#342 — fold 0xFF name. The narrow std::ifstream ctor on a UTF-8 operand string (ANSI-codepage decode, the niubash #88 class) swapped for file_io::open_binary_file across all 14 binary argv-operand readers: fold, csplit, expand, unexpand, fmt, du --exclude-from, less, utils/pager x2, ldd, column, more, strings, env --file, shuf --random-source. Text-mode readers (dircolors, hexdump -f, hostname -F) left for per-applet judgment (residual in the report).
#374 — mv quoteaf. gnu_quotearg gains shell_escape_quote_always (quoteaf); the port was validated against GNU mv on a 38-case byte battery before landing. Every mv operand rendering (diagnostics, prompts, not-replacing, verbose) routes through it; ordinary names render exactly as the old hand-written quoting. First CI run caught a helper-ordering C3861 (fixed) and i18n literal drift: the nine changed punctuation-fragment keys are recorded in scripts/i18n-drift-baseline.json via the gate's --update-baseline (the zh-CN catalog sync in winuxcmd-i18n is a follow-up for the captain).
#471 — printf %a. Determination: NOT version-relative. v8.32 printf.c (fetched) has the same STRTOX(long double, vstrtold) parse (line 356) and forced L modifier (665-673) as 9.4 (427-455) — both print through the C library %La, whose form is the constant. Renderer fixed to the glibc form (leading digit = top significand nibble, exponent exp-3, half-even precision rounding, carry -> digit 1 / exp+4); the subnormal arm was dead code under the Ext80 encoding and now shares the uniform path. Validated by a Python model against /usr/bin/printf on 4,480 cases before porting; the uutils#13867 tail-digit face is pinned.
#917 — shred dash. GNU rejects only tty-char / FIFO / socket stdout (shred.c:1257-1259, 816-853); the FILE_TYPE_DISK-only gate now matches that reject list (pipe or console-attached char rejected; everything else proceeds). GetFileSizeEx failure no longer reads an uninitialized size (size 0 -> no passes, rc 0; GNU hangs there without -s — deliberate practical divergence, recorded). Tests spawn shred by hand since the Pipeline harness always pipes stdout.
Every fix carries regression tests named for its issue. Note: files were formatted by hand to the surrounding style; the local clang-format is 23.1.3 (not project-pinned), so scripts/format was not run — each commit message says so. UNVERIFIED-BY-CAPTAIN: MSVC-only build, CI is the verifier.