Skip to content

WIP: fix(cmp,tac,printf): GNU message/split parity for #1443 #1444 #1445 - #1446

Merged
caomengxuan666 merged 3 commits into
mainfrom
fix/1443-1445-applets
Oct 29, 2026
Merged

caomengxuan666 merged 3 commits into
mainfrom
fix/1443-1445-applets

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Three applet fixes filed from the #1127 baseline-gate disposition work (wave-1b findings F1–F3). One commit per issue; oracle = GNU coreutils 9.4 / diffutils 3.10 as pinned by the differential corpus.

cmp (#1443) — the plain first-difference message now reads differ: char N, line M; only the -b form keeps differ: byte, and it appends each differing byte as %3o plus GNU's printable glyph (printable → itself, control → ^X, DEL → ^?, ≥0200 → M- over the low seven bits) instead of bare octals. The two stale unit pins move byte→char; new pins cover the -b wording and glyph classes. Corpus case corpus/cmp/14-differ.

tac (#1444) — -s '' is accepted for the literal split: an empty separator never occurs in the input, so the whole input is one record, printed verbatim. The blanket rejection in build_config (and its falsified "tac.c:528 rejects" comment) is gone; only the regex form still rejects it, with the same separator cannot be empty diagnostic GNU gives there. The unit pin that asserted the falsified behavior is replaced by three pins (verbatim via --separator= and via -s ''; regex form still rejected).

printf (#1445) — the invalid-conversion diagnostic drops its hard-coded quotes: printf: %y: invalid conversion specification. The source comment's GNU citation is corrected to the pinned-oracle text. New unit pin asserts exit 1, empty stdout, exact stderr. Corpus case regressions/52-printf-invalid-conversion.

i18n (AGENTS.md same-task rule) — the only catalog delta is one added legacy key, legacy.9f7e30c84b94c13b (" differ: char "), proven by before/after i18n_batch.py extract (3621 → 3622 keys, nothing removed/changed; both cmp literals stay bare safePrint calls so the extractor keeps cataloging them). The zh-CN sync + VERSION bump (0.6.23) is unixwin/winuxcmd-i18n#21 — merge it only after this branch lands, since merging publishes the catalog release. The tac literal survives (regex path), and the printf diagnostic is a dynamic fragment with no catalog entry.

Differential buckets: baseline.json/whitelist.txt untouched on purpose — the three corpus cases should flip to PASS in this PR's differential run; re-recording happens with the #1439 line.

Refs #1443
Refs #1444
Refs #1445

…phs (#1443)

GNU cmp's plain first-difference message reads "differ: char N,
line M"; only the -b form speaks of bytes, because it appends the
differing byte values. The applet printed "byte" in both forms and
appended bare octal values for -b, with no printable glyphs.

- print_difference: emit "differ: char" unless -b, "differ: byte"
  with -b (both literals stay bare safePrint calls, so the i18n
  extractor keeps cataloging them as legacy entries).
- -b suffix: " is %3o <glyph> %3o <glyph>" where the glyph follows
  GNU cmp.c: printable bytes stand for themselves, control bytes
  use caret notation (^@, ^A, ...), DEL is ^?, and bytes >= 0200
  carry an M- prefix over the low seven bits.
- Unit tests: the two plain-form expectations move byte -> char;
  new pins cover -b wording, octal+glyph pairs for printable,
  control, and high bytes (oracle: GNU diffutils 3.10 / coreutils
  9.4 differential corpus case corpus/cmp/14-differ).

Refs #1443
GNU tac accepts an empty separator for the literal split: it never
occurs in the input, so the whole input is a single record and is
printed verbatim. The applet rejected it in build_config for both
forms, under a comment citing tac.c:528 — a claim the pinned oracle
(coreutils 9.4, differential case regressions/50) falsifies. The
rejection is real only for -r: GNU reports "separator cannot be
empty" there, and keeps doing so here.

- build_config: the empty-separator error now fires only when the
  regex form was requested; the comment states both halves.
- split_literal_records: an empty separator returns the whole
  input as one record (find() of an empty needle would match at
  every position and never advance).
- Unit tests: the old tac_empty_separator_is_rejected pin asserted
  the falsified behavior and is replaced by three pins — literal
  empty separator via --separator= (verbatim, rc 0) and via -s ''
  (verbatim, rc 0), and the regex form still rejected with the
  exact diagnostic.

Refs #1444
The diagnostic hard-coded quotes around the directive:
"printf: '%y': invalid conversion specification". The pinned
oracle (coreutils 9.4 under LC_ALL=C, exactly as the differential
runner invokes it) prints the directive bare:
"printf: %y: invalid conversion specification", exit 1, no stdout
(differential case regressions/52). The source comment's GNU
citation carried the same spurious quotes and is corrected with
the code.

- render_once: drop the quotes from the safeErrorPrintLn format;
  the directive extraction itself (GNU %.*s shape) is unchanged.
- Unit test: new pin asserts exit 1, empty stdout, and the exact
  unquoted stderr for "%y".

Refs #1445
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 29, 2026 20:54
@caomengxuan666
caomengxuan666 merged commit 01da9b9 into main Oct 29, 2026
8 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 29, 2026
#1446

PR #1446 (merged to main as 01da9b9) fixed the three product
bugs these cases pin: cmp's plain differ message counts chars,
not bytes (#1443); tac accepts a literal empty -s separator
(#1444); printf's invalid-conversion diagnostic carries no
quotes (#1445). The two byte-identical two-sided result sets
harvested in wave-1d were produced on merge head faac22e, which
contains #1446, and all three cases come out PASS in both.

Re-record the observed buckets so the baseline states the
current expectation: corpus/cmp/14-differ OUT_DIFF -> PASS,
regressions/50-tac-empty-separator EXIT_DIFF -> PASS,
regressions/52-printf-invalid-conversion OUT_DIFF -> PASS.
The only-grows gate accepts improvements silently; recording
them makes any future flip back a flagged regression.

Refs #1127
@caomengxuan666
caomengxuan666 deleted the fix/1443-1445-applets branch October 30, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant