On 16/09/2021 08:26, Paul Eggert wrote:
Thanks for reporting that. I installed the attached to fix it.

Thanks to you both.
The fix looks good.

It got me thinking though, that we should not we warning/failing on blank lines.
I.e., we should be treating blank lines like comments.
The attached does that.

cheers,
Pádraig

>From 110556356911f1f2e0274eda803f8018f543266d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Thu, 16 Sep 2021 12:29:12 +0100
Subject: [PATCH] digest: ignore empty lines when checking

* src/digest.c (digest_check): Treat blank lines like comments,
as commented checksum files very often have blank lines.
* tests/misc/md5sum.pl: Adjust accordingly.
---
 src/digest.c         | 4 ++++
 tests/misc/md5sum.pl | 9 +++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/digest.c b/src/digest.c
index 9ee37a104..d13a05a3a 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -1075,6 +1075,10 @@ digest_check (char const *checkfile_name)
       line_length -= line[line_length - (0 < line_length)] == '\r';
       line[line_length] = '\0';
 
+      /* Ignore blank lines.  */
+      if (line_length == 0)
+        continue;
+
       if (! (split_3 (line, line_length, &hex_digest, &binary, &filename)
              && ! (is_stdin && STREQ (filename, "-"))))
         {
diff --git a/tests/misc/md5sum.pl b/tests/misc/md5sum.pl
index 09c2174f5..9b18219ac 100755
--- a/tests/misc/md5sum.pl
+++ b/tests/misc/md5sum.pl
@@ -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' => "invalid\n$degenerate  f\n"}},
                                 {OUT=>"f: OK\n"},
                                 {ERR=>"md5sum: "
                                  . "WARNING: 1 line is improperly formatted\n"},
-- 
2.26.2

Reply via email to