]> git.ipfire.org Git - thirdparty/coreutils.git/commit
digest: support windows format checksum files
authorPádraig Brady <P@draigBrady.com>
Tue, 14 Sep 2021 21:52:09 +0000 (22:52 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 15 Sep 2021 19:44:18 +0000 (20:44 +0100)
commited1c58427d574fb4ff0cb8f915eb0d554000ceeb
tree649ecf1130a12c63f95ccbd1daea35dc7261f600
parent7b8f38aa872de2b27174281db14e6a7ee043eb1b
digest: support windows format checksum files

Support checksum files with CRLF line endings,
which is a common gotcha for using --check on windows,
or with checksum files generated on windows.
Note we escape \r here to support the original coreutils format
(with file name at EOL), and file names with literal
\r characters as the last character of their name.

* src/digest.c (filename_unescape): Convert \\r -> \r.
(print_filename): Escape \r -> \\r.
(output_file): Detect \r chars in file names.
(digest_check): Ignore literal \r char at EOL.
* tests/misc/md5sum.pl: Add a test case.
* tests/misc/sha1sum.pl: Likewise.
* NEWS: Mention the improvement.
NEWS
doc/coreutils.texi
src/digest.c
tests/misc/md5sum.pl
tests/misc/sha1sum.pl