Skip to content

fix(cksum/split/comm/join): #1709 #1710 #1711 #1712 #1713 - #1747

Merged
caomengxuan666 merged 4 commits into
mainfrom
fix/text-1709-1713
Nov 14, 2026
Merged

caomengxuan666 merged 4 commits into
mainfrom
fix/text-1709-1713

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #1709 #1710 #1711 #1712 #1713. cksum rejects malformed CRC lines and drops crc32b; split -a overflow diagnostic; comm - - EBADF; join -z trailing field. Refs #1709 #1710 #1711 #1712 #1713

caomengxuan666 and others added 4 commits November 14, 2026 22:24
GNU split_3 (digest.c:783-791) accepts only records tagged with a
known non-legacy algorithm; WinuxCmd additionally treated its own
default "<sum> <size> <file>" CRC output as a valid check line, so
`cksum FILE > list; cksum -c list` round-tripped where GNU reports
"no properly formatted checksum lines found". The legacy fallback is
removed: untagged/default CRC lines are now counted as improperly
formatted (digest.c:1205-1212), `cksum_algorithm` is tracked across
files so -w diagnostics name the type in force, and the 10 tests that
encoded the extension were migrated to tagged MD5 records.

crc32b is not a GNU coreutils algorithm: it is removed from the
algorithm table so `-a crc32b` dies with the same "unsupported
digest type" diagnostic and valid-algorithm list as GNU 9.4.

Tests: 2 new unit tests + 10 migrated; corpus cases
cksum/50-check-rejects-crc-line, 51-crc32b-unsupported.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The -a diagnostic dropped the offending argument and every errno
suffix; it also capped the accepted length at 32 bits. Now
xdectoimax(optarg, 0, IDX_MAX, "", "invalid suffix length", 0)
(split.c:1385-1387) is mirrored: the whole argument is quoted, a
digit-run overflow appends ": Value too large for defined data type"
(EOVERFLOW), a clean scan below 0 appends ": Numerical result out of
range" (ERANGE), and a format failure carries EINVAL with no suffix.
The accepted range reaches idx_t (int64).

Three adjacent set_suffix_length gaps surfaced once the cap lifted:

- alpha_suffix pre-checked 26^length in uint64, dying "output file
  suffixes exhausted" for -a >= 15 where GNU only fails allocating
  the outfile buffer (split.c:397-401 xalloc_die -> "memory
  exhausted"); exhaustion is now detected per GNU -- leftover
  digits after `length` positions.
- suffix_auto widen (split.c:455-458) was value-odometer: GNU
  subsumes the last alphabet char into the prefix and restarts the
  suffix one char longer, so auto names run xaa..xyz then xzaaa
  (never xza..xzz), x00..x89 then x9000 under -d.
- the -n chunk modes now compute suffix_length_needed and reject a
  smaller user -a upfront ("the suffix length needs to be at least
  %d", split.c:204-211); --numeric-suffixes/--hex-suffixes= also
  disable suffix_auto (split.c:173-174).

I18N: new keys common.error.invalid_suffix_length,
common.error.result_out_of_range (ERANGE suffix strip),
command.split.error.suffix_length_min; "memory exhausted" rides the
legacy extraction path like "output file suffixes exhausted".

Tests: 3 new unit tests + corpus 60-64 (overflow/negative/invalid
-a, auto-widen, -n needed length).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Both '-' operands map to the same stdin FILE* (comm.c:292-300), so
the merge interleaves reads line by line. GNU then fclose()s both
operands (comm.c:390-391): the second fclose(stdin) fails EBADF and
comm dies with "comm: -: Bad file descriptor" before --total or the
"input is not in sorted order" summary. WinuxCmd's shared-queue
merge already interleaved correctly but exited 0 afterwards; it now
emits the EBADF diagnostic (key command.comm.error.bad_file_descriptor)
and returns 1, with per-file order warnings preserved.

Tests: 1 new unit test + corpus comm/60-both-stdin-ebadf,
61-both-stdin-total.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…1713)

-z sets eolchar=NUL (join.c:1106-1107) so newline-terminated input
reads as one record, and field_sep (system.h:163-166) always treats
'\n' as a blank separator. GNU xfields (join.c:273-303) then emits a
trailing empty field whenever the record ends in a separator, so
`join -z` on "a 1\nb 2\n" x "a X\nb Y\n" prints "a 1 b 2  X b Y \0".
The rust2 splitter skipped trailing separators; it now appends the
empty field, matching GNU byte-for-byte across -z/-a/-v/-o/-t and
non--z trailing-blank records.

Tests: rust test zero_terminated_newline_input_is_one_record + C++
pin + corpus join/50-z-newline-records.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant