summaryrefslogtreecommitdiff
path: root/src/md5sum.c
diff options
context:
space:
mode:
authorBenno Schulenberg <bensberg@justemail.net>2010-10-18 22:35:39 +0200
committerJim Meyering <meyering@redhat.com>2010-10-19 09:32:38 +0200
commit407806b27f032b3bce828ee0a152b5f67e997e09 (patch)
treebaf0156a6fd2232ca18c4843be3c7961854159b4 /src/md5sum.c
parent3c7112104daf8f7095048a3c5b2ee6f3e600521f (diff)
downloadcoreutils-407806b27f032b3bce828ee0a152b5f67e997e09.tar.xz
md5sum: print a summary warning for improperly formatted lines
And remove the now-superfluous totals from the other two warnings, so the plurals will also work in other languages than English. * src/md5sum.c (digest_check): Change as above. * tests/misc/md5sum (check-quiet2): Adjust accordingly.
Diffstat (limited to 'src/md5sum.c')
-rw-r--r--src/md5sum.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/md5sum.c b/src/md5sum.c
index 10d4fa26c..a660e3b2c 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -431,6 +431,7 @@ static bool
digest_check (const char *checkfile_name)
{
FILE *checkfile_stream;
+ uintmax_t n_misformatted_lines = 0;
uintmax_t n_properly_formatted_lines = 0;
uintmax_t n_mismatched_checksums = 0;
uintmax_t n_open_or_read_failures = 0;
@@ -489,6 +490,8 @@ digest_check (const char *checkfile_name)
&& ! (is_stdin && STREQ (filename, "-"))
&& hex_digits (hex_digest)))
{
+ ++n_misformatted_lines;
+
if (warn)
{
error (0, 0,
@@ -571,27 +574,26 @@ digest_check (const char *checkfile_name)
{
if (!status_only)
{
+ if (n_misformatted_lines != 0)
+ error (0, 0,
+ ngettext ("WARNING: %" PRIuMAX " line is improperly formatted",
+ "WARNING: %" PRIuMAX " lines are improperly formatted",
+ select_plural (n_misformatted_lines)),
+ n_misformatted_lines);
+
if (n_open_or_read_failures != 0)
error (0, 0,
- ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX
- " listed file could not be read",
- "WARNING: %" PRIuMAX " of %" PRIuMAX
- " listed files could not be read",
- select_plural (n_properly_formatted_lines)),
- n_open_or_read_failures, n_properly_formatted_lines);
+ ngettext ("WARNING: %" PRIuMAX " listed file could not be read",
+ "WARNING: %" PRIuMAX " listed files could not be read",
+ select_plural (n_open_or_read_failures)),
+ n_open_or_read_failures);
if (n_mismatched_checksums != 0)
- {
- uintmax_t n_computed_checksums =
- (n_properly_formatted_lines - n_open_or_read_failures);
- error (0, 0,
- ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX
- " computed checksum did NOT match",
- "WARNING: %" PRIuMAX " of %" PRIuMAX
- " computed checksums did NOT match",
- select_plural (n_computed_checksums)),
- n_mismatched_checksums, n_computed_checksums);
- }
+ error (0, 0,
+ ngettext ("WARNING: %" PRIuMAX " computed checksum did NOT match",
+ "WARNING: %" PRIuMAX " computed checksums did NOT match",
+ select_plural (n_mismatched_checksums)),
+ n_mismatched_checksums);
}
}