Repository navigation
#1488 borrow uutils algorithms - #1575
Merged
Merged
Conversation
…borrow-algo) Root cause: the float generation path stepped in f64 where GNU uses 80-bit long double (seq.c print_numbers, lines 300-364), so >17-digit decimal operands rounded at parse and sub-f64-ulp steps looped forever (seq 0.9999999999999999999 1e-19 1.0000000000000000002 printed 1.0000000000000000000 forever; the audit case seq 0.9999999999999999999 1.0000000000000000002 printed 1.0000000000000000000 instead of 0.9999999999999999999). Fix: std-only exact-decimal path. Operands parse as (i128 mantissa, decimal scale) pairs, the loop steps on the common 10^-scale grid, output formats from the scaled integers only. The seq.c rounding fixup (lines 340-356) is dead here: the value just past LAST sits on the 10^-prec grid so its rendering never reparses to LAST. A parity guard admits only magnitudes under the long-double 64-bit mantissa grid (< 2^64 units of 10^-prec over first/last/|last-first|); the probed boundary keeps 0.99999999999999999999 (GNU parses to 1.0) on the float path. The scientific-integer fast attempt renders endpoints from the exact mantissa (GNU %0.Lf of the long double, seq.c lines 686-695): seq 1e23 1e23 was 99999999999999991611392, now 100000000000000000000000. Gate: sq51-sq60 (audit case, -w, sub-ulp, 1e23, 1000-step no-drift, 18/19-digit grids, negative zero, both ld boundary shapes). Evidence: rust2/target/borrow-algo/seq-probe*.txt, 33/33 GNU 9.4 parity.
…borrow-algo) Root cause: under auto-padding the per-field pad width ignored GNU's 1 < field rule (numfmt.c process_suffixed_number line 1360: padding_width = text < p || 1 < field ? mbswidth (text) : 0), so a converted field past the first collapsed the line to single spaces: echo 'plain 1048576 line' | numfmt --field 2 --to=iec gave 'plain 1.0M line' instead of GNU's 'plain 1.0M line'. Fix: one invariant correction — auto-padding uses the full field-text width whenever the field carries leading blanks or is past the first, so the converted number is padded back to its original field width and trailing fields keep their columns. Byte length stands in for mbswidth (ASCII = gate domain; wide multibyte is a documented divergence, and GNU's own strlen fallback applies to unprintable bytes). Explicit --padding and --delimiter still disable auto-padding (numfmt.c line 1687). Gate: nf75-nf86 (--field 1/2/3/-/2-3/1,3/4 over aligned multi-space lines, tab separators, invalid=warn, wider output, delimiter/padding opt-outs, suffix/format-suffix width). Evidence: rust2/target/borrow-algo/numfmt-probe*.txt, 20/21 GNU 9.4 parity (the 1 is stderr smart-quote wording, never gated).
caomengxuan666
force-pushed
the
rust2/borrow-algo
branch
from
November 12, 2026 03:54
810f637 to
4241a05
Compare
This was referenced Nov 13, 2026
aphrody-labs Bot
pushed a commit
to aphrody-labs/WinuxCmd
that referenced
this pull request
Nov 15, 2026
…nixwin#1488) Owner-directed follow-up to unixwin#1562 (which covered only the coreutils monorepo): audit the four uutils SIBLING repos that own our 2.0 big unimplemented commands. Method: shallow clones (target/uutils-siblings/, HEADs 2026-11-10..12), three-party semantic sampling (WSL GNU 5.3.20 / our C++ build-1496 / uutils debug builds), 8 cases per command, raw output in target/uutils-siblings/sampling/threeway_all.txt. Key findings: - All four repos outsource regex: grep+findutils delegate to Oniguruma C (onig/onig_sys); sed = bre_to_ere translation -> regex crate with fancy-regex fallback for backrefs; diffutils ships a 360-line BRE translator over the regex crate. NO repo has a portable std-only Rust POSIX engine -> regex decision A (port portable_regex) stands; sed's bre_to_ere + diffutils bre.rs become cross-check corpora. - IO: all four are process-level stdio; unixwin#1488 explicit-IO contract would require rewriting each repo's output layer (grep worst, diffutils lib layer best). - Deps: 119-167 transitive packages per repo incl. a C library (onig_sys) -> route C (adopt crates) conflicts with std-only policy. - Sampling: grep 8/8, sed 8/8, find 6/8 (uu walks print backslash paths while -printf prints forward slashes; localized -newer error), diff 7/8 for uu (missing -i) — and two OUR-side 1.x divergences found: cmp says "char 7" vs GNU/uu "byte 7"; diff -r recursion header prints redundant "diff diff -r ..." full args. Recommendation: route B (borrow algorithms, unixwin#1575 precedent) as the mainline with A carrying the engine; per-command table in the doc.
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.
Borrow-algo action items from the uutils audit (DOCS/2.0-uutils-audit.md §4.1/§4.2, PR #1562): seq exact fixed-point decimal stepping and numfmt --field line reassembly.
seq — exact fixed-point stepping
seq 0.9999999999999999999 1.0000000000000000002printed1.0000000000000000000instead of GNU's0.9999999999999999999.0.9999999999999999999is admitted,0.99999999999999999999(GNU long double parses to 1.0) stays on the float path. The scientific-integer fast attempt renders endpoints from the exact mantissa (GNU prints "%0.Lf" of the long double, lines 686-695):seq 1e23 1e23was99999999999999991611392, now100000000000000000000000.seq 0.9999999999999999999 0.0000000000000000001 1.0000000000000000002looped forever printing1.0000000000000000000.numfmt — --field reassembly keeps the original field width
1 < fieldrule (numfmt.c process_suffixed_number line 1360:padding_width = text < p || 1 < field ? mbswidth (text) : 0), so a converted field past the first collapsed the line:echo 'plain 1048576 line' | numfmt --field 2 --to=iecgaveplain 1.0M lineinstead of GNU'splain 1.0M line.Gate (same tables, same harness)
Notes / residual
seq 2 1e-19 2.0000000000000000005duplicates lines;-1.5 0.9999999999999999999 1.5drifts a final ulp). We now print exact decimals there (uutils-equivalent behavior); documented in the module comment, outside the gate.printf %s, so the\nescape stays literal and single-value numfmt rows (the nf01-nf28 class) pass vacuously through the invalid-suffix error path on both sides. Suggested follow-up recorded in the report.Closes the borrow items of #1488. Not merging — captain to review.