On Sun, Apr 6, 2008 at 1:10 PM, Jim Meyering <[EMAIL PROTECTED]> wrote:
> Please use VC_LIST_EXCEPT, so that the checks look only
> at version-controlled files. That also provides a method
> for exceptions: see the existing .x-sc_* files.
Ah, that's much nicer. Thanks.
> s/Likwise/Likewise/ ;-)
Yikes. :)
Bo
From fda400023db314046b6792b1b51c242b2bb62996 Mon Sep 17 00:00:00 2001
From: Bo Borgerson <[EMAIL PROTECTED]>
Date: Fri, 4 Apr 2008 11:13:13 -0400
Subject: [PATCH] Standardize some error messages.
* maint.mk: (sc_error_message_warn_fatal, sc_error_message_uppercase):
(sc_error_message_period): Add automatic checks for non-standard error messages.
* .x-sc_error_message_uppercase: explicit exclusion for this check
* src/cp.c: Standardize some error messages.
* src/date.c: Likewise.
* src/dircolors.c: Likewise.
* src/du.c: Likewise.
* src/expr.c: Likewise.
* src/install.c: Likewise.
* src/join.c: Likewise.
* src/ln.c: Likewise.
* src/mv.c: Likewise.
* src/od.c: Likewise.
* src/pr.c: Likewise.
* src/split.c: Likewise.
* src/wc.c: Likewise.
* tests/du/files0-from: Expect new error message.
* tests/misc/wc-files0-from: Likewise.
* tests/misc/xstrtol: Likewise.
* lib/xmemxfrm.c: Likewise.
Signed-off-by: Bo Borgerson <[EMAIL PROTECTED]>
---
.x-sc_error_message_uppercase | 1 +
lib/xmemxfrm.c | 4 ++--
maint.mk | 23 +++++++++++++++++++++++
src/cp.c | 2 +-
src/date.c | 4 ++--
src/dircolors.c | 4 ++--
src/du.c | 2 +-
src/expr.c | 4 ++--
src/install.c | 10 +++++-----
src/join.c | 2 +-
src/ln.c | 2 +-
src/mv.c | 2 +-
src/od.c | 2 +-
src/pr.c | 8 ++++----
src/split.c | 2 +-
src/wc.c | 2 +-
tests/du/files0-from | 2 +-
tests/misc/wc-files0-from | 2 +-
tests/misc/xstrtol | 3 +--
19 files changed, 52 insertions(+), 29 deletions(-)
create mode 100644 .x-sc_error_message_uppercase
diff --git a/.x-sc_error_message_uppercase b/.x-sc_error_message_uppercase
new file mode 100644
index 0000000..2452230
--- /dev/null
+++ b/.x-sc_error_message_uppercase
@@ -0,0 +1 @@
+build-aux/cvsu
diff --git a/lib/xmemxfrm.c b/lib/xmemxfrm.c
index 039f978..84f5158 100644
--- a/lib/xmemxfrm.c
+++ b/lib/xmemxfrm.c
@@ -52,9 +52,9 @@ xmemxfrm (char *restrict dest, size_t destsize,
if (errno)
{
error (0, errno, _("string transformation failed"));
- error (0, 0, _("Set LC_ALL='C' to work around the problem."));
+ error (0, 0, _("set LC_ALL='C' to work around the problem"));
error (exit_failure, 0,
- _("The untransformed string was %s."),
+ _("the untransformed string was %s"),
quotearg_n_style_mem (0, locale_quoting_style, src, srcsize));
}
diff --git a/maint.mk b/maint.mk
index 6933a3c..c8fe53e 100644
--- a/maint.mk
+++ b/maint.mk
@@ -143,6 +143,29 @@ sc_error_exit_success:
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
exit 1; } || :
+# `FATAL:' should be fully upper-cased in error messages
+# `WARNING:' should be fully upper-cased, or fully lower-cased
+sc_error_message_warn_fatal:
+ @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
+ | grep -E '"Warning|"Fatal|"fatal' && \
+ { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
+ exit 1; } || :
+
+# Error messages should not start with a capital letter
+sc_error_message_uppercase:
+ @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
+ | grep -E '"[A-Z]' \
+ | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
+ { echo '$(ME): found capitalized error message' 1>&2; \
+ exit 1; } || :
+
+# Error messages should not end with a period
+sc_error_message_period:
+ @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
+ | grep -E '[^."]\."' && \
+ { echo '$(ME): found error message ending in period' 1>&2; \
+ exit 1; } || :
+
sc_file_system:
@grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found use of "file''system";' \
diff --git a/src/cp.c b/src/cp.c
index 3f95871..6dd2e7e 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -592,7 +592,7 @@ do_copy (int n_files, char **file, const char *target_directory,
{
if (target_directory)
error (EXIT_FAILURE, 0,
- _("Cannot combine --target-directory (-t) "
+ _("cannot combine --target-directory (-t) "
"and --no-target-directory (-T)"));
if (2 < n_files)
{
diff --git a/src/date.c b/src/date.c
index ba88eb8..f9973f9 100644
--- a/src/date.c
+++ b/src/date.c
@@ -444,8 +444,8 @@ main (int argc, char **argv)
{
error (0, 0,
_("the argument %s lacks a leading `+';\n"
- "When using an option to specify date(s), any non-option\n"
- "argument must be a format string beginning with `+'."),
+ "when using an option to specify date(s), any non-option\n"
+ "argument must be a format string beginning with `+'"),
quote (argv[optind]));
usage (EXIT_FAILURE);
}
diff --git a/src/dircolors.c b/src/dircolors.c
index 2a90075..e33723b 100644
--- a/src/dircolors.c
+++ b/src/dircolors.c
@@ -450,8 +450,8 @@ to select a shell syntax are mutually exclusive"));
error (0, 0, _("extra operand %s"), quote (argv[!print_database]));
if (print_database)
fprintf (stderr, "%s\n",
- _("File operands cannot be combined with "
- "--print-database (-p)."));
+ _("file operands cannot be combined with "
+ "--print-database (-p)"));
usage (EXIT_FAILURE);
}
diff --git a/src/du.c b/src/du.c
index 6681079..d6789f8 100644
--- a/src/du.c
+++ b/src/du.c
@@ -937,7 +937,7 @@ main (int argc, char **argv)
{
error (0, 0, _("extra operand %s"), quote (argv[optind]));
fprintf (stderr, "%s\n",
- _("File operands cannot be combined with --files0-from."));
+ _("file operands cannot be combined with --files0-from"));
usage (EXIT_FAILURE);
}
diff --git a/src/expr.c b/src/expr.c
index cd498f6..f5b3415 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -780,9 +780,9 @@ eval2 (bool evaluate)
if (errno)
{
error (0, errno, _("string comparison failed"));
- error (0, 0, _("Set LC_ALL='C' to work around the problem."));
+ error (0, 0, _("set LC_ALL='C' to work around the problem"));
error (EXPR_INVALID, 0,
- _("The strings compared were %s and %s."),
+ _("the strings compared were %s and %s"),
quotearg_n_style (0, locale_quoting_style, l->u.s),
quotearg_n_style (1, locale_quoting_style, r->u.s));
}
diff --git a/src/install.c b/src/install.c
index 1d04373..5318a35 100644
--- a/src/install.c
+++ b/src/install.c
@@ -412,8 +412,8 @@ main (int argc, char **argv)
case PRESERVE_CONTEXT_OPTION:
if ( ! selinux_enabled)
{
- error (0, 0, _("Warning: ignoring --preserve-context; "
- "this kernel is not SELinux-enabled."));
+ error (0, 0, _("WARNING: ignoring --preserve-context; "
+ "this kernel is not SELinux-enabled"));
break;
}
x.preserve_security_context = true;
@@ -422,8 +422,8 @@ main (int argc, char **argv)
case 'Z':
if ( ! selinux_enabled)
{
- error (0, 0, _("Warning: ignoring --context (-Z); "
- "this kernel is not SELinux-enabled."));
+ error (0, 0, _("WARNING: ignoring --context (-Z); "
+ "this kernel is not SELinux-enabled"));
break;
}
scontext = optarg;
@@ -479,7 +479,7 @@ main (int argc, char **argv)
{
if (target_directory)
error (EXIT_FAILURE, 0,
- _("Cannot combine --target-directory (-t) "
+ _("cannot combine --target-directory (-t) "
"and --no-target-directory (-T)"));
if (2 < n_files)
{
diff --git a/src/join.c b/src/join.c
index b8a0011..52655a9 100644
--- a/src/join.c
+++ b/src/join.c
@@ -383,7 +383,7 @@ check_order (const struct line *prev,
{
error ((check_input_order == CHECK_ORDER_ENABLED
? EXIT_FAILURE : 0),
- 0, _("File %d is not in sorted order"), whatfile);
+ 0, _("file %d is not in sorted order"), whatfile);
/* If we get to here, the message was just a warning, but we
want only to issue it once. */
diff --git a/src/ln.c b/src/ln.c
index aa0e473..645255e 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -508,7 +508,7 @@ main (int argc, char **argv)
{
if (target_directory)
error (EXIT_FAILURE, 0,
- _("Cannot combine --target-directory "
+ _("cannot combine --target-directory "
"and --no-target-directory"));
if (n_files != 2)
{
diff --git a/src/mv.c b/src/mv.c
index 44f5bfc..b4e7cf1 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -450,7 +450,7 @@ main (int argc, char **argv)
{
if (target_directory)
error (EXIT_FAILURE, 0,
- _("Cannot combine --target-directory (-t) "
+ _("cannot combine --target-directory (-t) "
"and --no-target-directory (-T)"));
if (2 < n_files)
{
diff --git a/src/od.c b/src/od.c
index 250a02d..9730ec7 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1841,7 +1841,7 @@ it must be one character from [doxn]"),
{
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
error (0, 0, "%s\n",
- _("Compatibility mode supports at most one file."));
+ _("compatibility mode supports at most one file"));
usage (EXIT_FAILURE);
}
}
diff --git a/src/pr.c b/src/pr.c
index 77d4c8a..4d76b12 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -914,7 +914,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, 0,
_("`--pages=FIRST_PAGE[:LAST_PAGE]' missing argument"));
else if (! first_last_page (oi, 0, optarg))
- error (EXIT_FAILURE, 0, _("Invalid page range %s"),
+ error (EXIT_FAILURE, 0, _("invalid page range %s"),
quote (optarg));
break;
}
@@ -1100,11 +1100,11 @@ main (int argc, char **argv)
if (parallel_files & explicit_columns)
error (EXIT_FAILURE, 0,
- _("Cannot specify number of columns when printing in parallel."));
+ _("cannot specify number of columns when printing in parallel"));
if (parallel_files & print_across_flag)
error (EXIT_FAILURE, 0,
- _("Cannot specify both printing across and printing in parallel."));
+ _("cannot specify both printing across and printing in parallel"));
/* Translate some old short options to new/long options.
To meet downward compatibility with other UNIX pr utilities
@@ -2395,7 +2395,7 @@ print_header (void)
print_white_space ();
if (page_number == 0)
- error (EXIT_FAILURE, 0, _("Page number overflow"));
+ error (EXIT_FAILURE, 0, _("page number overflow"));
/* The translator must ensure that formatting the translation of
"Page %"PRIuMAX does not generate more than (sizeof page_text - 1)
diff --git a/src/split.c b/src/split.c
index f84d40e..9372e03 100644
--- a/src/split.c
+++ b/src/split.c
@@ -190,7 +190,7 @@ next_file_name (void)
sufindex[i] = 0;
outfile_mid[i] = suffix_alphabet[sufindex[i]];
}
- error (EXIT_FAILURE, 0, _("Output file suffixes exhausted"));
+ error (EXIT_FAILURE, 0, _("output file suffixes exhausted"));
}
}
diff --git a/src/wc.c b/src/wc.c
index 61ab485..c18948e 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -633,7 +633,7 @@ main (int argc, char **argv)
{
error (0, 0, _("extra operand %s"), quote (argv[optind]));
fprintf (stderr, "%s\n",
- _("File operands cannot be combined with --files0-from."));
+ _("file operands cannot be combined with --files0-from"));
usage (EXIT_FAILURE);
}
diff --git a/tests/du/files0-from b/tests/du/files0-from
index 4d9b37c..9a26c64 100755
--- a/tests/du/files0-from
+++ b/tests/du/files0-from
@@ -38,7 +38,7 @@ my @Tests =
# invalid extra command line argument
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
{ERR => "du: extra operand `no-such'\n"
- . "File operands cannot be combined with --files0-from.\n"
+ . "file operands cannot be combined with --files0-from\n"
. "Try `du --help' for more information.\n"}
],
diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from
index 61340d6..f9b17ed 100755
--- a/tests/misc/wc-files0-from
+++ b/tests/misc/wc-files0-from
@@ -39,7 +39,7 @@ my @Tests =
# invalid extra command line argument
['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
{ERR => "$prog: extra operand `no-such'\n"
- . "File operands cannot be combined with --files0-from.\n"
+ . "file operands cannot be combined with --files0-from\n"
. "Try `$prog --help' for more information.\n"}
],
diff --git a/tests/misc/xstrtol b/tests/misc/xstrtol
index 874b4a5..a2f8501 100755
--- a/tests/misc/xstrtol
+++ b/tests/misc/xstrtol
@@ -49,9 +49,8 @@ my @Tests =
['simply-inval', "--pages=x", {EXIT => 1},
{ERR=>"$prog: invalid --pages argument `x'\n"}],
- # FIXME: should be lower case "invalid".
['inv-pg-range', "--pages=9x", {EXIT => 1},
- {ERR=>"$prog: Invalid page range `9x'\n"}],
+ {ERR=>"$prog: invalid page range `9x'\n"}],
);
my $save_temps = $ENV{DEBUG};
--
1.5.2.5
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils