Repository navigation
WIP: audit W2 coreutils text faces vs oracle source (Refs #1462) - #1471
Merged
Merged
Conversation
#1462) Oracle: coreutils 9.4 sources (~/workspace/winuxcmd-audit). - tsort: ready set is a FIFO queue with successors in reverse reading order (tsort.c record_relation/T4-T7); '-' names stdin (tsort.c:435); extra operand is a usage error with try-help (tsort.c main); odd-token diagnostic carries the input name (tsort.c:472); open failure uses the errno diagnostic form (tsort.c tsort()). - od: accept the obsolescent traditional letters -B -D -e -F -H -h -I -L -O -X mapped per od.c CASE_OLD_ARG; format specifications now accumulate in argv order instead of a fixed flag order; -i/-l help text corrected to the implemented dI/dL sizes. - ptx: add --format=roff|tex (ptx.c case 10), resolved last-wins with -O/-T over the occurrence list, argmatch diagnostic on a bad value; -C/--copyright retagged [EXT] (absent from GNU ptx). - uniq: --group/--all-repeated invalid values now produce the GNU argmatch diagnostic with valid-argument lists (uniq.c XARGMATCH). - sort: --sort uses true argmatch semantics -- case-sensitive unique-prefix match over sort_args -- with the argmatch diagnostic and exit 1, mirroring the existing --check treatment. Differential cases 75-85 pin each fix.
Oracle: coreutils 9.4 digest.c (HASH_ALGO_SUM) + sum.c. - sum: -r has no long form in GNU (digest.c longopts for SUM lists only --sysv); the invented --bsd spelling was accepted and selected BSD. Removed; choose_algorithm now keys on the short name only. - sum: a read failure returned the fixed string "error reading from file"; GNU reports per file as "sum: '<file>': <strerror>" (digest.c digest_file error path). Route through the existing open-error wording helper so the file and reason are named. i18n: option surface change (--bsd removed from help) -- catalog companion noted in REPORT.md.
…1462) Oracle: coreutils 9.4 shuf.c. - -e with -i dies "cannot combine -e and -i options" + usage (shuf.c:488-492); operands with -i and a second file operand die "extra operand '<arg>'" + usage, naming operand[0]/operand[1] respectively (shuf.c:493-497). Both were silently accepted. - A second -i dies "multiple -i options specified" (shuf.c:412); a second DIFFERENT -o / --random-source dies "multiple output files specified" / "multiple random sources specified" (shuf.c:458-467); identical repeats stay legal. - -r with a nonzero head count on empty input dies "no lines to repeat" (shuf.c:574-580) instead of exiting 0 silently. - -n 0 short-circuits input preparation (shuf.c:500-504): a missing input file is no longer an error; the -o file is still created. - -o open failure now reports "shuf: '<path>': <reason>" (shuf.c freopen error path) instead of a bare fixed string. Residual (named in REPORT.md): -i endpoints are still narrowed to int64_t and -r/--random-source ranges are still materialised eagerly (shuf.c uses size_t endpoints and on-the-fly draws). i18n: new diagnostic strings -- catalog companion noted in REPORT.md.
Oracle: coreutils 9.4 digest.c (HASH_ALGO_CKSUM) + cksum.c.
- -l/--length: the CRC exemption is removed -- any nonzero length
with a non-blake2b algorithm dies "--length is only supported
with --algorithm=blake2b" (digest.c:1474-1477), and the
multiple-of-8 check now fires for every algorithm as it does
while parsing in GNU (digest.c case 'l').
- --tag with --check verifies normally: the "meaningless" usage
error exists only for the non-cksum digest programs
(digest.c:1540-1548, #if !HASH_ALGO_CKSUM).
- --ignore-missing with nothing verified now FAILS and prints
"cksum: '<list>': no file was verified" (digest.c:1325-1327,
1330-1335); the old code forced success.
- WARNING summaries: the improperly-formatted summary is no longer
gated on -w; the mismatch summary drops the invented "of M"
part ("WARNING: N computed checksum(s) did NOT match");
the per-line -w diagnostic names the digest type
(DIGEST_TYPE_STRING, digest.c:1205-1212).
- --status/--quiet/-w are resolved as one sequential state from
the occurrence list, last one wins (digest.c getopt cases).
- --debug: the invented per-file triples are removed; in 9.4 the
flag only reports CRC pclmul support (cksum.c:150-160).
Kept as named extensions (REPORT.md): the crc32b algorithm value
(post-9.4 coreutils) and untagged default-CRC --check records.
i18n: diagnostic wording changes -- catalog companion noted in
REPORT.md.
Oracle: coreutils 9.4 csplit.c.
- The regexp closing delimiter is the LAST one (strrchr,
csplit.c:1097): /a/b/ is the regexp "a/b", not regexp "a"
plus a bogus offset.
- Unsigned regexp offsets are positive (check_for_offset /
xstrtoimax): /re/5 is valid; integer patterns accept a leading
'+' (xstrtoumax), and 0 dies with "0: line number must be
greater than zero" (csplit.c:1153).
- -n/--digits loses the invented 32 cap (xdectoimax bound is
INT_MAX, csplit.c:1334) and reports "invalid number: '<arg>'".
- -f '' is honored as an empty prefix (prefix = optarg
unconditionally) instead of falling back to xx.
- -b suffix formats: the ' (thousands) flag is accepted, and
'#'/quote flags incompatible with the conversion die with
"invalid flags in conversion specification: %<flag><conv>"
(check_format_conv_type).
- A token starting with '{' that is not a well-formed repeat dies
with "<tok>: '}' is required in repeat count"
(parse_repeat_count) instead of being reparsed as a pattern.
- Missing-operand diagnostics take the GNU forms "missing
operand" / "missing operand after '<file>'" (csplit.c:1361-
1363), and an unopenable input names the errno reason
(csplit.c:612).
i18n: diagnostic wording changes -- catalog companion noted in
REPORT.md.
Oracle: coreutils 9.4 nl.c. - Numbering styles are judged by their FIRST character (build_type_arg): -b ax / -b t2 / -h nnn are accepted and act as a/t/n; proc_text switches on the same first character. - Lines are copied byte-exactly: an unterminated final line no longer gains a newline, and under -bt it counts as empty when it is a single character (nl.c:358 tests the length including the newline). - An unopenable file no longer aborts the run: main accumulates ok &= nl_file (...) and later operands are still processed, exit 1 overall; the diagnostic takes GNU's bare form "nl: <file>: <reason>" (nl.c:451). - -w widths above 63 are honored (the 64-byte snprintf buffer truncated them); the field buffer is sized to the width. - The UTF-8 BOM is no longer stripped from a file's first line; GNU treats the bytes as content. i18n: diagnostic wording changes -- catalog companion noted in REPORT.md.
Oracle: coreutils 9.4 fold.c. - The default mode now counts BYTES like GNU's getc loop with adjust_column (tab to the next multiple of 8, backspace -1, CR to 0, every other byte +1); UTF-8 codepoint decoding (with wide codepoints counting 2) survives only in the -c extension mode (audit: a 3-byte character folded as 3 columns, not 2). - Width parsing: a leading '+' is accepted, widths are kept in 64 bits instead of wrapping through int, and zero/overflow report the full form "invalid number of columns: '<arg>': Numerical result out of range" (fold.c:281, xdectoimax). - An explicitly empty -w '' is an invalid width, not an absent option. - The UTF-8 BOM is no longer stripped from regular files. - The open-error diagnostic takes GNU's bare form "fold: <file>: <reason>" (fold.c:138). Named extension (REPORT.md): -c/--characters (a coreutils 9.5 addition, absent from the 9.4 oracle). i18n: diagnostic wording changes -- catalog companion noted in REPORT.md.
…Refs #1462) Oracle: coreutils 9.4 expand.c + expand-common.c. - Repeated -t accumulates into one shared tab list (parse_tab_stops appends): -t 4 -t 8 is {4, 8}, not last-wins {8}. The obsolescent -NUM form now adds its stop at its own argv position (specs are collected from the occurrence list in argv order), so -8 -t 4 hits GNU's fatal "tab sizes must be ascending" instead of being silently reordered into {4, 8}. - Specifier diagnostics take the GNU wordings: "'/' specifier not at start of number: '<rest>'" for a specifier after digits, "'/' specifier only allowed with the last value" (and the '+' twin) for a misplaced repeat, and "'/' specifier is mutually exclusive with '+'" from the validate phase. - The UTF-8 BOM is no longer stripped from regular files. i18n: diagnostic wording changes -- catalog companion noted in REPORT.md.
…(Refs #1462) Oracle: coreutils 9.4 unexpand.c + expand-common.c. - Pending blanks are flushed at end of line: an unterminated final line no longer loses its trailing blanks (printf 'ab ' now yields "ab ", and an all-blanks unterminated input no longer vanishes). - The -f short alias for --first-only is removed: GNU gives --first-only no short form, so -f is an invalid option there. - Repeat-specifier validation spans all -t specs: a '/' spec combined with a '+' spec dies with "'/' specifier is mutually exclusive with '+'" (validate_tab_stops) instead of the later spec silently overwriting the repeat mode; misplaced specifiers take the GNU wordings ("not at start of number", "only allowed with the last value"). - The UTF-8 BOM is no longer stripped by default. Named residual (REPORT.md): the obsolescent comma digit form -4,8 cannot be expressed through the framework's generic -NUM option. i18n: option surface + diagnostic wording changes -- catalog companion noted in REPORT.md.
…ce counting, -n partitions, separator rules (Refs #1462) Oracle: coreutils-9.4 src/split.c. - parse_size now requires full consumption (parse_n_units / xstrtoimax): '10junk' and '1.5K' are invalid instead of silently truncating. The multiplier alphabet is exactly "bEGKkMmPQRTYZ0" (split.c:1355): lowercase e/g/t/p removed; Q/R/Y/Z added with a saturate sentinel (1024^7+ overflows int64; GNU parses OVERFLOW_OK). - FAIL_ONLY_ONE_WAY (split.c:1290-1295) counts option OCCURRENCES, so -l 2 -l 3 dies; mode presence no longer conflates an empty value with absence (-b ''/-l ''/-n '' now reach their own parse errors, split.c:1548-1620). - -n l2/r2 without the slash now die as invalid numbers of chunks; only the exact l//r/ prefixes select those modes. - -t: collects every value from both spellings; '' -> "empty record separator", length>1 other than the two-character \0 spelling -> "multi-character separator '<arg>'", differing repeats -> "multiple separator characters specified" (split.c:1457-1479). The invented \n/\t mappings are gone. - -d/-x resolve by argv order via the occurrence list (getopt order); the last one wins. - -a: the 32 cap is removed (xdectoimax to IDX_MAX). - Suffix widening grows by one, not two (xzz -> xaaa). - --verbose "creating file" goes to stdout (create(), split.c). - -n N bytes: bytes_split(file_size/N, file_size%N) -- the first remainder chunks get the extra byte (10 bytes / 3 -> 4,3,3, verified against the 9.4 binary). - -n l/N: lines_chunk_split partitions BYTES (same boundaries); a record belongs to the file where it starts (verified against the 9.4 binary). Record-count partitioning removed. - -n forms create all N files even for empty input. - NOT changed: -C file filling. An audit hypothesis claimed GNU fills the current file with the head of an over-long record; running the oracle 9.4 binary on 'ab\n' + a 12-byte line with -C 10 produces 'ab\n' / 'cdefghijkl' / 'm\n' -- lines are flushed whole and long lines split in their own chunk sequence, exactly the existing implementation. The hypothesis was a misreading of line_bytes_split's hold logic; no change made.
…paragraphs, crown/tagged breaks (Refs #1462) Oracle: coreutils-9.4 src/fmt.c. - -w is capped at MAXCHARS/2 = 2500 (xdectoumax, fmt.c:395-404): larger widths die 'invalid width: ...: Numerical result out of range'. -g keeps its existing cap by the width in force. - -w ''/-g '' are parsed on presence, not non-emptiness, and die 'invalid width: ''' like GNU. - -p goes through set_prefix (fmt.c:457-474): leading and trailing spaces are stripped from the argument, the leading-space count becomes an eligibility floor for a line's indent column (fmt.c:563), and output indents are rebuilt as spaces + the trimmed prefix instead of re-attaching the raw matched text. - A blanks-only line is a paragraph separator whose blanks are consumed: a bare newline is emitted (get_paragraph/copy_rest), not the blanks verbatim. - Paragraph membership uses columns (in_column; a tab advances to the next multiple of 8): a tab and eight spaces now form one paragraph. - Crown and tagged paragraphs end when a later line's column differs from the second line's (fmt.c:591-617); a tagged second line with the SAME column as the first starts a new paragraph instead of joining. The old flush-time re-split is gone. - Tagged one-line paragraphs use set_other_indent's DEF_INDENT rule: continuation indent 3 when the first indent is 0, else 0 (fmt.c:516-529). - The file-branch UTF-8 BOM strip is removed; GNU has no BOM handling (and the stdin branch never stripped, so the old code was also internally inconsistent). Impl-only options -m/-P/-x/-X/-T are unchanged and remain extensions; -T is also no longer labelled [GNU].
…-f pad_down, -N validation, -c/-v table, raw input (Refs #1462) Oracle: coreutils-9.4 src/pr.c; several points verified against the 9.4 binary on this machine. - +FIRST[:LAST] and --pages=FIRST[:LAST] (first_last_page, pr.c:804-833): LAST_PAGE is honored in all three pagination paths. A bad --pages dies 'invalid page range '<arg>'' (pr.c:913-922); a bad + operand is a FILE name, as in pr.c case 1 (verified: 'pr +0 f' reports '+0: No such file or directory'). The invented 'invalid page number' is gone. - -D FORMAT is actually used, via a strftime subset (C-locale names) instead of a hard-coded date; the POSIXLY_CORRECT default '%b %e %H:%M %Y' (pr.c:1063-1066) is honored. Seconds are now populated by both time producers for %S. - -h '' is expressible via a header_set flag (pr.c:964-965). - Input form feeds paginate (hold_file/read_line): read_lines splits lines at '\f' with a sentinel; the single-column path ends the page there -- emitted as a bare '\f' under -t (keep_FF, pr.c:1880), dropped under -T, normal page end otherwise. Column modes strip the sentinel (residual). - -f: pad_down (pr.c:2095-2105) -- one '\f' REPLACES the page-end newline padding at every page end; the old code emitted both. - -N is validated at option time (getoptnum, pr.c:991-995): 'pr -N abc' dies ''-N NUMBER' invalid starting line number: 'abc'' instead of throwing out of std::stoi mid-pagination. - -c/-v follow char_to_clump: tab is never converted, -v wins over -c for every non-printing byte, -c renders bytes >= 0x80 in octal. One combined pass replaces the sequential transforms. - Input is raw: the CRLF strip and BOM strip in read_lines are removed. The cannot-open diagnostic takes GNU's form 'pr: <name>: No such file or directory' (quotef, plain for ordinary names; verified). - The invented 'starting page number N exceeds page count M' diagnostic is removed: GNU skip_to_page fails silently. - Column-count errors take GNU's wording 'invalid number of columns: '<arg>'' (parse_column_count, pr.c:839-843). - NOT changed: header margin placement (audit divergence 7). Byte-level check against the 9.4 binary shows GNU emits the margin before the first newline too (print_header's pad_across_to + print_white_space precede the printf), so GNU and the implementation produce identical bytes; the audit note missed the pre-printf padding. No change made. - --expand / --balance-columns long forms re-labelled [EXT] (GNU has only --expand-tabs and short -b).
…open diagnostic, BOM, delimiter diagnostic (Refs #1462) Oracle: coreutils-9.4 src/paste.c. - Serial mode prints a lone line delimiter for a completely empty file (paste_serial: EOF is not the delimiter, paste.c:424-431); the old code printed nothing. - Serial mode treats a failed open as non-fatal per file: diagnose, continue with the remaining files, exit 1 at the end (paste.c:382-389). Parallel mode still stops before any output, as GNU does. - Open diagnostics take the GNU form 'paste: <file>: <errno text>' in both modes (paste.c:237, 385). - The UTF-8 BOM strip in the file branch is removed; paste is byte-oriented and the stdin branch never stripped (the old code also disagreed with itself). - The trailing-backslash diagnostic names the offending list: 'delimiter list ends with an unescaped backslash: <arg>' (paste.c:506-514).
…orm (Refs #1462) Oracle: coreutils-9.4 src/comm.c. - comm - - now merges over ONE shared stdin stream with interleaved pulls (comm.c:303): FILE1's first line is physical line 1, FILE2's is line 2, and each consumed line pulls the next physical line into its own stream. The old code slurped stdin into FILE1 and left FILE2 empty (its own comment even asserted the slurp model as GNU's). Column suppression, --total, and the order-check modes are mirrored in the pull-based path. - Open diagnostics take the GNU form 'comm: <file>: <errno text>' (comm.c:303-305), for missing files and directories alike. - Residual: LC_COLLATE collation (comm.c xmemcoll) is not implemented; comparisons stay bytewise, which is identical in the C locale.
…rding, up-front regex validation (Refs #1462) Oracle: coreutils-9.4 src/tac.c. - A literal empty -s is a one-byte NUL separator (match_length = *separator ? strlen : 1, tac.c:540), verified against the 9.4 binary ('a\0b\0c' | tac -s '' -> 'cb\0a\0'). The #1444 'never occurs' reading holds only for NUL-free input; both comments that asserted it are corrected. - Open failures use tac's own wording 'failed to open <file> for reading: <reason>' (tac.c:460), translated from the shared reader's head/tail 'cannot open' form. - The -r separator is compiled once before any file is read (tac.c:534): 'tac -r -s "[" missing' now reports the regex error once ('Invalid regular expression', the regerror text for that pattern) instead of the file error, and multi-file runs no longer repeat a per-file lowercase message.
…output check, read-error shapes (Refs #1462) Oracle: coreutils-9.4 src/cat.c. - -E (without -v) renders a CR immediately before LF as ^M, via a pending_cr hold across chunk boundaries (cat.c:475); other CRs stay raw. Probed GNU: 'x\r\n' | cat -E -> 'x^M$'. - Line numbers widen past 6 digits instead of wrapping modulo 1,000,000 (next_line_num, cat.c:133): line 1,000,000 now prints '1000000\t', not ' 0'. - Input-is-output check (cat.c:713): when stdout is a regular file with the same volume/file identity as a non-empty input operand, the operand fails with 'cat: <file>: input file is output file' and nothing is copied. - Read-error diagnostics take GNU's shape 'cat: <operand>: <strerror>' (cat.c:186, 342) for '-', /dev/stdin operands, and regular files; the bare ''-' fragment and the invented 'error reading' wording are gone. (The strerror text is the EIO mapping; an ifstream bad() carries no errno on Windows.)
…n ignored, error continuation, impl-only options removed (Refs #1462) Oracle: coreutils-9.4 src/set-fields.c + src/cut.c; list shapes verified against the 9.4 binary. - The LIST parser is now the set-fields scan: an element ends on ',', a blank, or end of string ('1 2' valid; '1, 2', '1 2', ' 2', '2 ' contain an empty element and fail). Diagnostics: 'invalid field value '<rest>'' / 'invalid byte/character position '<rest>'', 'field number <n> is too large' / 'byte/character offset <n> is too large', 'invalid field range' / 'invalid byte or character range', 'invalid range with no endpoint: -', 'invalid decreasing range', and the numbered-from-1 texts reserved for zero/empty values. The old parser used the numbered-from-1 text for every failure and accepted a lone '-' as 1-. - Any second list option (even the same one twice, even empty) dies 'only one list may be specified' (cut.c:515-527); a missing list dies 'you must specify a list of bytes, characters, or fields'. Presence, not non-emptiness, counts: -b '' reaches the parser and fails numbered-from-1. - -d and -s in non-field modes have their distinct GNU texts (cut.c:563-569), not one conflated message. - All build_config failures now get the Try line (FATAL_ERROR). - -n is ignored, as GNU documents (cut.c:159, 549-550): its former --no-partial whole-span byte semantics are removed. - Open errors take the GNU form 'cut: <file>: <errno text>', and run() accumulates over all operands (cut.c:595-596) instead of stopping at the first bad file. - The impl-only options -w/--whitespace-delimited, -F, -O (short form), --no-partial (long form), and -M are removed: GNU rejects those spellings, and -w/-F implemented a whitespace field mode GNU cut does not have.
… octals, class order (Refs #1462) Oracle: coreutils-9.4 src/tr.c. - GNU's validate() (tr.c:1435-1495) is now implemented in its own order, driven by parse metadata the parser newly tracks (equiv classes, class spans, element starts, ends-with-class): [=c=] in string2 when translating is fatal; string2 classes other than upper/lower are fatal when translating; validate_case_classes rejects a string2 case class that does not start exactly where a string1 case class starts ('misaligned [:upper:] and/or [:lower:] construct'); an empty string2 without -t is fatal; a shorter string2 ending in a character class is fatal instead of being padded; and with -c plus a class in string1, string2 must be same-length and homogeneous. The old code performed none of these checks and silently produced invented translations. - A well-formed [=...=] whose content is not one character is fatal: '<operand>: equivalence class operand must be a single character' (tr.c:913-925), instead of degrading to literal characters. - Ambiguous octal escapes \400-\777 follow unquote: the set gains the two-digit value plus the third digit literally, with 'warning: the ambiguous octal escape \400 is being interpreted as the 2-byte sequence \040, 0' (tr.c:471-512). - [:blank:] is TAB, SPACE and [:space:] is TAB, LF, VT, FF, CR, SPACE (ascending byte order, tr.c:1055-1067); the old space-first tables swapped positional mappings. - An empty class name reports 'missing character class name '[::]'' (tr.c:884) instead of the generic invalid-class text.
…pec diagnostics, join-field order (Refs #1462) Oracle: coreutils-9.4 src/join.c. - Multiple -o options accumulate (add_field_list); a real list beats 'auto' regardless of order. -o '' and trailing/doubled separators are fatal with decode_field_spec's texts: 'invalid file number in field spec: '<item>'', 'invalid field specifier: '<item>''; the old parser skipped empty items and used generic messages. - A second different -e dies 'conflicting empty-field replacement strings'; a second different -t dies 'incompatible tabs'; a multi-char -t reports 'multi-character tab '<arg>'' (join.c case 't'). -t '' sets the '\n' tab, which is also the output separator. - --check-order/--nocheck-order resolve in argv order, last wins; --nocheck-order no longer always wins. - -1/-2/-j are applied in argv order, so 'incompatible join fields' reports the already-set value first (join.c:917-924): '-j 3 -1 2' now reports '2, 1'. - -a/-v accept xstrtol spellings like '01' (value checked, not the string). - A directory operand reports 'read error: Is a directory' (the fopen-succeeds/read-fails shape, join.c:497). - Residual: LC_COLLATE collation (xmemcoll) is not implemented; comparisons stay bytewise (identical in the C locale).
…r files, obsolete -NUMz (Refs #1462) Oracle: coreutils-9.4 src/head.c. - string_to_integer is xdectoumax with suffix alphabet 'bkKmMGTPEZYRQ0' (head.c:913): a suffix with no digits now means 1 x suffix ('head -c K' = 1024 bytes), leading whitespace and an inner '+' are consumed as strtoumax does, lowercase k/m join the table, and overflow reports 'invalid number of lines|bytes: '<value>': Value too large for defined data type' instead of the plain invalid text. The quoted operand is the string head.c hands to the parser: a leading '-' (the elide marker) stripped, a leading '+' kept ('head -n -abc' quotes 'abc'; '-n +abc' quotes '+abc'). - Regular files no longer route through the text decoder when the sample carries a BOM or a NUL: head counts raw bytes and raw records for files; the decoder probe remains only where it was already used for console-style input. - The dispatcher's obsolete-count rewrite accepts the 'z' suffix letter ('head -2z' = '-n 2 -z'); an unknown trailing letter still falls through to option parsing -- GNU's exact 'invalid trailing option -- <c>' text (head.c:1064-1067) has no channel in the rewrite API and is named as a residual in the cluster report.
…-unchanged-stats/-s diagnostics, stdin follow, obsolete forms (Refs #1462) Oracle: coreutils-9.4 src/tail.c. - A zero count with no -f and no '+' form returns success before opening anything (tail.c:2378): 'tail -n 0 missing' no longer errors. - --follow resolves through argmatch: unambiguous prefixes of 'descriptor'/'name' work; '' is 'ambiguous argument ... for '--follow'' and other junk is 'invalid argument ...', both with the Valid-arguments list. The old 'invalid follow mode' text is gone. - --pid and --max-unchanged-stats are parsed by tail itself (options re-registered as strings): 'invalid PID: '<v>'', 'invalid maximum number of unchanged stats between opens: '<v>''. --pid is a single value -- last wins, 0 clears -- not an accumulating vector. - -s reports 'invalid number of seconds: '<v>'', the last of -s/--sleep-interval wins, and the interval keeps double precision instead of truncating to whole milliseconds. - The count grammar matches head's xdectoumax: suffix-only values ('tail -c K'), lowercase k/m, and an unknown suffix is a plain invalid number -- the old code misreported it as EOVERFLOW. - Line mode on regular files and on redirected stdin takes the byte path; the text decoder remains only for a real console. - -f now follows a regular-file stdin (fd 0 resolved via GetFinalPathNameByHandle), as tail.c follows the descriptor. - Dispatcher: the digit-less obsolete forms -l/-b/-lf/-bf/-cf (count 10; bare '-c' is the live option, not obsolete -- tail.c parse_obsolete_option), and an obsolete count in first position with two or more file operands now hits 'option used in invalid context -- N'. - Impl-only extensions kept and labelled: --debug, --use-polling.
… -w/-m/-L Unicode rules, directory lines, name quoting (Refs #1462) Oracle: coreutils-9.4 src/wc.c; every behavior below was also verified against the system GNU wc 9.4. - --total resolves through argmatch BEFORE any file is opened: unambiguous prefixes accepted ('--total=al' = always); 'a' and '' are 'ambiguous argument ... for '--total'' and junk is 'invalid argument ...', both with the Valid-arguments list. The old code validated after counting with 'invalid --total value'. - --files0-from keys on presence: '--files0-from=' tries to open '' ('cannot open '' for reading: ...'). A list file that cannot open reports that same 'cannot open' shape. Bad records no longer abort the list: a zero-length name reports 'wc: <list>:<record#>: invalid zero-length file name' and a '-' name from stdin reports its diagnostic, the remaining names are still counted, and the exit status fails. An empty list succeeds silently. Combined operands report GNU's two lines: 'extra operand '<first>'' + 'file operands cannot be combined with --files0-from'. - -w: word separators are the UTF-8 iswspace set (U+1680, U+2000-200A, U+2028/2029, U+205F, U+3000, plus the no-break spaces unless POSIXLY_CORRECT); C0/C1/DEL codepoints neither start nor break a word. - -m: bytes that are not valid UTF-8 are consumed but not counted as characters. - -L: combining-character ranges have width 0. - A directory operand prints its zero count line, then 'wc: <dir>: Is a directory', exit 1 (the line was dropped). - Names containing a newline print in quotef shell-escape form ('a'$'\n''b.txt') in count lines and diagnostics. - Residuals (report): --debug's text is an impl invention; the number-width heuristic for streamed inputs differs from wc.c's fstat-based width in corner cases.
…1462) Follow-up to the tr validate() commit, caught by checking the new code against GNU tr 9.4: with -c, string1's length in the length/ends-in-class checks is the complemented domain size (256 - distinct string1 bytes), so 'tr -c a [:upper:]' reports 'when translating with string1 longer than string2, the latter string must not end with a character class' instead of falling through to the complemented-domain mapping error. The same domain length now bounds the homogeneous-mapping check and its indefinite-repeat fill.
…#1462) One or more live-compared cases per fixed command: cksum, csplit, nl, fold, expand, unexpand, split, fmt, pr, paste, comm, tac, cat, cut, tr, join, head, tail, wc. Not cased, by design (see the cluster report): sum --bsd removal (the framework's unrecognized-option wording is not GNU's), shuf (nondeterministic output), comm - - (GNU's own output is a stdio-buffering artifact with a spurious EBADF diagnostic).
The occurrences-loop call site passes meta.short_name, which is a std::string_view (cmd_meta.cppm); the lambda declared it const std::string&, which MSVC rejects (C2664 at join.cpp:315). The body only compares the name against literals, so a view is the correct parameter type; value stays const std::string& because parse_positive_field takes one. Refs #1462 Refs #1471
GNU wc.c prints the total when 1 < argv_iter_n_args (ai), and that count includes records that were diagnosed and skipped (zero-length names, wc.c:955-971; '-' read from stdin, wc.c:941-952). The product based the decision on the surviving path count, so a list with one valid name plus one bad record lost its total line. Files0ReadResult now reports records_seen and process_command uses it as the --files0-from basis. The two skip-case unit pins are corrected to the same contract: valid neighbor still counted, total line present, '<list>:<rec#>:' diagnostic prefix, exit 1. The old pins asserted empty stdout and an unprefixed diagnostic, which no GNU shape produces.
Eight pins asserted shapes no GNU build produces; each was checked
against coreutils-9.4 source and a 9.4 oracle binary:
- wc --files0-from empty file/stdin: NOT an error -- wc.c main
loop falls through with ok unchanged (nothing read, exit 0).
Renamed *_is_an_error -> *_succeeds.
- wc --files0-from + named operand: diagnostic is the two-line
'extra operand' / 'file operands cannot be combined with
--files0-from' (wc.c:864-866), not '--files0-from disallows'.
- wc --files0-from missing list: fopen branch reports 'cannot
open <F> for reading: <reason>' (wc.c:877-878), not the operand
shape.
- wc --files0-from directory list: POSIX surfaces it at read
('<F>: read error: Is a directory', wc.c AI_ERR_READ); Windows
cannot open a directory at all, so the reachable GNU branch is
cannot-open with the true reason. Old pin matched neither.
- wc directory OPERAND: wc() still calls write_counts after the
EISDIR read error -- the zero line prints; only the status
fails. Old pin asserted empty stdout.
- uniq --group=bad: XARGMATCH (uniq.c:595, table uniq.c:123-126)
via argmatch.c:145 prints 'invalid argument <v> for --group'
plus the valid-argument list; 'invalid grouping method' does
not exist in GNU uniq.
Product code already implements every one of these shapes; only
the pins were stale.
…nsensitively (Refs #1462) The product pads the count fields to GNU's computed width (a directory operand yields the width-7 layout, exactly like coreutils 9.4's own output), so the literal '0 0 0' substring never appears. Squash whitespace before asserting the zero counts + name shape; exit status and the EISDIR diagnostic assertions were already passing.
The framework resolves the short and long spelling of an option to the same meta slot (command_context.cppm: get/has/get_all match on either name), so summing get_all() over both spellings counted every list occurrence twice: list_count was 2 for any single -b/-c/-f and every valid invocation died with "only one list may be specified". Use ctx.count(), which walks the raw occurrences once. GNU semantics preserved: any second list occurrence is fatal (cut.c:515) and no list at all is fatal (cut.c, audit #1462). Refs #1462
- -w/-F/--whitespace-delimited/-O have no GNU spelling (cut.c optstring "b:c:d:f:nsz"); the feature tests for the removed spellings now pin the invalid/unrecognized-option diagnostics. - -n is a pure no-op (cut.c:536-537): the split-character test now expects the selected byte to pass through instead of being dropped by the former --no-partial invention. - open errors use the bare quotef form (cut.c:455), not "cannot open ... for reading". Refs #1462
occurrences_of() summed get_all() over the long and short spelling, but both resolve to the same framework meta slot, so one -l/-b/-C/-n counted as two selections and every mode invocation died with "cannot split in more than one way" (GNU: FAIL_ONLY_ONE_WAY counts each selection once, split.c:1290-1295). Use ctx.count(). The -t value list concatenated both spellings too; one get_all returns every occurrence already. Refs #1462
get_all() by either spelling returns every occurrence of the one meta slot; concatenating the --input-range and -i lists doubled each value, so a single -i died with "multiple -i options specified" (GNU raises that only for a real second -i, shuf.c:409-412). Same duplication removed for --head-count (MIN semantics per shuf.c:451 unchanged) and --output. Refs #1462
All eight failures were invented expectations; the product mirrors
digest.c:1294-1335 already:
- the improperly-formatted WARNING summary prints by default and
under --strict (not gated on --warn), digest.c:1300-1307;
- the --warn per-line diagnostic names the digest type
("improperly formatted CRC checksum line", digest.c:1209);
- the mismatch summary is "WARNING: 1 computed checksum did NOT
match" (digest.c:1320) -- no "1 of 1 computed checksums" form;
- --ignore-missing with nothing verified fails with "no file was
verified" (digest.c:1316-1319);
- -l is only valid with --algorithm=blake2b, so the short/long
alias equivalence test runs there.
The untagged-CRC --check line acceptance itself is the deliberate
extension recorded as residual R-cksum and is untouched.
Refs #1462
Every needle here pinned an invented "cannot open '<f>' for reading: ..." form. GNU 9.4 (verified against the system binaries and the oracle sources): - comm/fold/paste/nl: bare quotef "<cmd>: <f>: <reason>" (fold.c:138; the products already emit it); - tac: open failures take "failed to open %s for reading" (tac.c:460) -- the product translates the shared reader's prefix; the trailing-slash case matches GNU exactly, the directory case takes the open wording because a Windows directory fails at open (GNU's "read error" site, tac.c:474, is the Linux shape); - tac -s '' is a 1-byte NUL separator (tac.c:540), so NUL records reverse; the "single record" pin held only for NUL-free input; - join: "join: read error: Is a directory", no file name (join.c:497); - csplit: the standard "missing operand" / "missing operand after '<f>'" diagnostics, not "missing input file"/"missing pattern". Refs #1462
The rendered paragraph indent was rebuilt as indent spaces + the trimmed prefix only, dropping the padding up to the first word's column. GNU put_line (fmt.c:986-991) prints prefix_indent spaces, the trimmed prefix, then pads to the line's indent column -- so "> alpha" keeps its blank and ">alpha" stays attached, and the two shapes are different paragraphs. The attachment string now carries the pad (which also corrects the DP's line lengths), and crown/tagged continuation lines render with the second line's attachment (other_indent, fmt.c:508-529). Covers the fmt -p unit pins and regressions/93-fmt-prefix. Refs #1462
parse_obsolete_option (tail.c:2062-2067) recognizes the obsolete form only with at most one file operand (or a '--' in argv[2]); outside the gate a leading '+' is a file name in the standard form (tail.c:2080). The rewrite now applies the same gate, and the invalid-context validator fires it only for '-' counts: 'tail +2l f1 f2' opens '+2l' as an operand and prints the files whole instead of dying or being rewritten to -n +2. Refs #1462
- tail +2l with two files: '+2l' is an operand (argc gate), the files print whole, exit 1 -- not a from-start selection. - tail repeated --pid: scalar last-wins (tail.c), not a wait set; the pin now orders short-then-long and expects the follow to survive the first pid's death. - head/tail BOM and UTF-16LE pins: head.c/tail.c are byte-oriented; BOM bytes pass through and UTF-16LE is not transcoded (first/last line = raw bytes at 0x0A boundaries). Supersedes the removed decode behavior. Refs #1462
- fold -w counts bytes by default (fold.c): the UTF-8 pin now expects the byte split GNU produces, not display width. - pr keeps CRLF verbatim (pr.c has no CR trimming). - uniq --all-repeated argmatch needle: GNU quotes both the argument and the option name. Refs #1462
- sum issue1370 last-wins: GNU has no --bsd long option (sum.c); pinned with --sysv then -r instead. - sort --sort=M: argmatch is case-sensitive (sort.c XARGMATCH) and 'M' matches nothing; the pin uses --sort=month. The invalid-word pin now expects GNU's exit 1 + argmatch text. - unexpand -f: no such GNU option (unexpand.c; --first-only is long-only); the pin now expects the invalid-option error. Refs #1462
…s-text # Conflicts: # src/commands/wc.cpp
The invalid/ambiguous argument error listed the valid arguments but dropped GNU's closing line (tail.c via argmatch): 'Try 'tail --help' for more information.' (regressions/110). Refs #1462
GNU's TeX output (ptx.c) is \xx {tail}{before}{keyword}{after}
{headline}: the keyword stands alone and the after group keeps
its leading blank. The emitter merged keyword+context into one
trimmed group like roff does -- roff merging is correct for
roff, wrong for TeX (regressions/81).
Refs #1462
The default-mode half pinned the removed UTF-8 decode behavior (BOM consumed, blanks converted from column 0). GNU unexpand is byte-oriented: the BOM makes the following blanks non-initial, so default output is verbatim; the -a half already pinned the byte-column conversion and passes. Refs #1462
GNU od.c computes width_per_block as the max of (field_width + 1) * fields_per_block over all specs and deals each spec's pad_width out field by field (PRINT_FIELDS, od.c:425-447); the renderer used a fixed width + 1 slot per field, which only agrees for a single spec. Multi-spec blocks (-D -e -H -O; -t x1 -b) now lay out byte-identically, and the hexl trailer pad uses od.c:1213-1222's formula instead of a per-byte heuristic. Refs #1462
- number-line CRLF and l/2/3 pins expected an equal-record partition; lines_chunk_split partitions BYTES into near-equal ranges and a record belongs to the range its first byte falls in (split.c) -- GNU gives partaa='a\r\nb\r\n' and chunk 2/3 = 'c\nd', exactly what the product produces. - empty-separator needle: GNU's text is 'empty record separator' (the product already emits it). - --verbose reports go to stdout (split.c create()); the pin checked stderr. Refs #1462
caomengxuan666
marked this pull request as ready for review
October 31, 2026 21:01
This was referenced Nov 1, 2026
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.
Oracle-audit cluster W2 for #1462: coreutils text faces (cat tac head tail sort uniq wc cut tr join comm paste csplit split fmt fold expand unexpand nl od pr ptx tsort shuf cksum sum), audited per-command against the coreutils 9.4 C sources (contract = option table, operand rules, exit codes, diagnostics, edge semantics; clean-room, behavior facts only).
Batch 1 (this push):
-= stdin (tsort.c:435); extra-operand usage error + try-help; odd-token diagnostic carries the input name (tsort.c:472); open failure in GNU errno form.--format=roff|texadded (ptx.c case 10), last-wins with -O/-T, argmatch diagnostic; -C/--copyright retagged [EXT].--group/--all-repeatedinvalid values → GNU argmatch diagnostic + valid lists.--sort→ true argmatch (case-sensitive unique prefixes over sort_args), argmatch diagnostic, exit 1, mirroring --check.Differential cases 75–85 added per fix. Remaining commands of the family are being audited in follow-up commits on this branch; a per-command verdict table lands in the workdir REPORT.md.
Notes: cannot build locally (MSVC-only) — CI is the gate. Standing noise: regressions/70-env; cache-400 is infra. Source formatting matched by hand (no clang-format in the audit environment). User-visible string changes (od -i/-l help, ptx -O/-T/--format help) get their winuxcmd-i18n companion before this leaves draft.