]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cksum: accept new option: --base64 (-b)
authorJim Meyering <meyering@fb.com>
Sat, 21 Jan 2023 02:09:26 +0000 (18:09 -0800)
committerJim Meyering <meyering@meta.com>
Wed, 1 Feb 2023 02:24:28 +0000 (18:24 -0800)
commitb319685c6e12e66bf357c2384fe69f1c63f66aed
tree2b3239e4ecbe14df1dbbf54d70a9937f42e4432b
parent7a8db7dbafc932cb08403b863a1c1edec5d283ca
cksum: accept new option: --base64 (-b)

* src/digest.c [HASH_ALGO_CKSUM]: Include "base64.h"
[HASH_ALGO_CKSUM] (base64_digest): New global.
[HASH_ALGO_CKSUM] (enum BASE64_DIGEST_OPTION): New enum.
[HASH_ALGO_CKSUM] (long_options): Add "base64".
(valid_digits): Rename from hex_digits, now taking an input length argument.
Adjust callers.
(bsd_split_3): Rename arg from hex_digits to digest.
Add new *d_len parameter for length of extracted digest.
Move "i" declaration down to first use.
(split_3): Rename arg from hex_digits to digest.
Add new *d_len parameter for length of extracted digest.
Instead of relying on "known" length of digest to find the following
must-be-whitespace byte, search for the first whitespace byte.
[HASH_ALGO_CKSUM] (output_file): Handle base64_digest.
[HASH_ALGO_CKSUM] (main): Set base64_digest.
[HASH_ALGO_CKSUM] (b64_equal): New function.
(hex_equal): New function, factored out of digest_check.
(digest_check) Factored part into b64_equal and hex_equal.
Rename local hex_digest to digest.
* tests/misc/cksum-base64.pl: Add tests.
* tests/local.mk (all_tests): Add to the list.
* cfg.mk (_cksum): Define.
(exclude_file_name_regexp--sc_prohibit_test_backticks): Exempt new test.
(exclude_file_name_regexp--sc_long_lines): Likewise.
* doc/coreutils.texi (cksum invocation): Document it.
(md5sum invocation) [--check]: Mention digest encoding auto-detect.
* NEWS (New Features): Mention this.
NEWS
cfg.mk
doc/coreutils.texi
src/digest.c
tests/local.mk
tests/misc/cksum-base64.pl [new file with mode: 0755]