diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-11-03 09:49:50 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-11-04 23:30:15 +0000 |
commit | ed2326ac367a77b1d88493e96ccebdd36f596cdb (patch) | |
tree | 618c4925ccd44cc805bc74a21ef3675343b145fb | |
parent | 08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (diff) | |
download | coreutils-ed2326ac367a77b1d88493e96ccebdd36f596cdb.tar.xz |
test: use consistent quoting
* src/test.c (test_syntax_error): Reuse verror() rather than
open coding the error output format.
(term): Don't hardcode '' quoting.
(main): Likewise.
-rw-r--r-- | src/test.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/test.c b/src/test.c index 65226c535..ee6d7ddd4 100644 --- a/src/test.c +++ b/src/test.c @@ -48,6 +48,9 @@ #include "stat-time.h" #include "strnumcmp.h" +#include <stdarg.h> +#include "verror.h" + #if HAVE_SYS_PARAM_H # include <sys/param.h> #endif @@ -81,17 +84,16 @@ static bool term (void); static bool and (void); static bool or (void); -static void test_syntax_error (char const *format, char const *arg) +static void test_syntax_error (char const *format, ...) ATTRIBUTE_NORETURN; static void beyond (void) ATTRIBUTE_NORETURN; static void -test_syntax_error (char const *format, char const *arg) +test_syntax_error (char const *format, ...) { - fprintf (stderr, "%s: ", argv[0]); - fprintf (stderr, format, arg); - fputc ('\n', stderr); - fflush (stderr); + va_list ap; + va_start (ap, format); + verror (0, 0, format, ap); test_exit (TEST_FAILURE); } @@ -240,10 +242,11 @@ term (void) value = posixtest (nargs); if (argv[pos] == 0) - test_syntax_error (_("')' expected"), NULL); + test_syntax_error (_("%s expected"), quote (")")); else if (argv[pos][0] != ')' || argv[pos][1]) - test_syntax_error (_("')' expected, found %s"), quote (argv[pos])); + test_syntax_error (_("%s expected, found %s"), + quote_n (0, ")"), quote_n (1, argv[pos])); advance (false); } @@ -857,7 +860,7 @@ main (int margc, char **margv) } } if (margc < 2 || !STREQ (margv[margc - 1], "]")) - test_syntax_error (_("missing ']'"), NULL); + test_syntax_error (_("missing %s"), quote ("]")); --margc; } |