digest: ignore empty lines when checking

* src/digest.c (digest_check): Treat empty lines like comments,
as commented checksum files very often have empty lines.
* tests/misc/md5sum.pl: Adjust accordingly.
This commit is contained in:
Pádraig Brady committed 2021-09-16 20:39:28 +01:00
1 parent 7ebcd88fb2
commit e6c57cf19b
2 files changed
+8 -6

No files matched your search

+5
View File
@@ -1073,6 +1073,11 @@ digest_check (char const *checkfile_name)
line_length -= line[line_length - 1] == '\n';
/* Remove any trailing carriage return. */
line_length -= line[line_length - (0 < line_length)] == '\r';
/* Ignore empty lines. */
if (line_length == 0)
continue;
line[line_length] = '\0';
if (! (split_3 (line, line_length, &hex_digest, &binary, &filename)
+3 -6
View File
@@ -53,18 +53,15 @@ my @Tests =
{IN=> {'f.md5' => "$degenerate f\r\n"}},
{OUT=>"f: OK\n"}],
# Same as above, but with an added empty line, to provoke --strict.
# Same as above, but with an added empty line, to test --strict.
['ck-strict-1', '--check --strict', {AUX=> {f=> ''}},
{IN=> {'f.md5' => "$degenerate f\n\n"}},
{OUT=>"f: OK\n"},
{ERR=>"md5sum: "
. "WARNING: 1 line is improperly formatted\n"},
{EXIT=> 1}],
{OUT=>"f: OK\n"}],
# As above, but with the invalid line first, to ensure that following
# lines are processed in spite of the preceding invalid input line.
['ck-strict-2', '--check --strict', {AUX=> {f=> ''}},
{IN=> {'in.md5' => "\n$degenerate f\n"}},
{IN=> {'in.md5' => "ERR\n$degenerate f\n"}},
{OUT=>"f: OK\n"},
{ERR=>"md5sum: "
. "WARNING: 1 line is improperly formatted\n"},