Repository navigation
cksum --raw / tree -o / split --filter: stop writing through CRT text mode - #1219
Merged
Merged
Conversation
Member
Author
|
Verification (Release / MSVC,
Bytes were always compared against WSL coreutils 9.4 with |
caomengxuan666
force-pushed
the
fix/write-side-binary-output
branch
from
October 17, 2026 07:10
39052f8 to
918e415
Compare
3 tasks done
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.
What
Fixes #1214. Three write paths handed their bytes to a CRT stream that was
still in Windows text mode, so every
0x0Ain the payload was rewrittenas
0D 0A.cksum --raw47 8b 0d 0a 06(5 bytes)47 8b 0a 06(4 bytes)tree -o FILEN directories, M filessummarysplit --filter=cata\r\nb\r\nc\r\na\nb\nc\nChanges
src/commands/cksum.cpp—_setmode(_fileno(stdout), _O_BINARY)inrun(), next to the existing stdin switch, sofwrite(..., stdout)of araw digest is verbatim (same idiom as
sort/uniq/tee/tr/yes).src/commands/tree.cpp— open the-ostream withstd::ios::binaryand emit the summary line in file mode too.
src/commands/split.cpp—_setmode(_fileno(pipe), _O_BINARY)after_popen()so--filterchildren receive the exact chunk bytes.Tests
*_issue1214unit tests intests/unit/{cksum,tree,split}:cksum_raw_preserves_0x0a_digest_byte_issue1214— asserts the 4 raw CRCbytes for
"x"*66 + "\n"(CRC3247 8b 0a 06).tree_output_file_is_lf_only_and_keeps_summary_issue1214— asserts the-ofile is CR-free and carries the summary, matching stdout.split_filter_pipe_delivers_lf_only_bytes_issue1214— filter child seesa\n/b\nexactly.Verification
Built with
scripts/build-with-vs.ps1(Release, MSVC) and run through thewinuxcmd-teststarget; new tests pass, no pre-existing test incksum/tree/split regressed. Bytes were cross-checked against WSL coreutils
9.4 with
python(bytes), never with the in-treeod.Note for reviewers:
cksum.cppis also touched by the parallel stdin-binarywork (#1195/#1199/#1200). This change is strictly the stdout mode line in
run(); it does not touch any reader.