@@ -20,6 +20,11 @@ use crate::{show, translate};
2020/// from it: 32 KiB.
2121const READ_BUFFER_SIZE : usize = 32 * 1024 ;
2222
23+ /// Necessary options when computing a checksum. Historically, these options
24+ /// included a `binary` field to differentiate `--binary` and `--text` modes on
25+ /// windows. Since the support for this feature is approximate in GNU, and it's
26+ /// deprecated anyway, it was decided in #9168 to ignore the difference when
27+ /// computing the checksum.
2328pub struct ChecksumComputeOptions {
2429 /// Which algorithm to use to compute the digest.
2530 pub algo_kind : SizedAlgoKind ,
@@ -30,9 +35,6 @@ pub struct ChecksumComputeOptions {
3035 /// Whether to finish lines with '\n' or '\0'.
3136 pub line_ending : LineEnding ,
3237
33- /// On windows, open files as binary instead of text
34- pub binary : bool ,
35-
3638 /// (non-GNU option) Do not print file names
3739 pub no_names : bool ,
3840}
@@ -42,6 +44,12 @@ pub struct ChecksumComputeOptions {
4244/// On most linux systems, this is irrelevant, as there is no distinction
4345/// between text and binary files. Refer to GNU's cksum documentation for more
4446/// information.
47+ ///
48+ /// As discussed in #9168, we decide to ignore the reading mode to compute the
49+ /// digest, both on Windows and UNIX. The reason for that is that this is a
50+ /// legacy feature that is poorly documented and used. This enum is kept
51+ /// nonetheless to still take into account the flags passed to cksum when
52+ /// generating untagged lines.
4553#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
4654pub enum ReadingMode {
4755 Binary ,
@@ -280,7 +288,9 @@ where
280288
281289 let mut digest = options. algo_kind . create_digest ( ) ;
282290
283- let ( digest_output, sz) = digest_reader ( & mut digest, & mut file, options. binary )
291+ // Always compute the "binary" version of the digest, i.e. on Windows,
292+ // never handle CRLFs specifically.
293+ let ( digest_output, sz) = digest_reader ( & mut digest, & mut file, /* binary: */ true )
284294 . map_err_context ( || translate ! ( "checksum-error-failed-to-read-input" ) ) ?;
285295
286296 // Encodes the sum if df is Base64, leaves as-is otherwise.
0 commit comments