mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
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.
This commit is contained in:
1 parent
08e8fd7e38
commit
ed2326ac36
1 file changed
+12
-9
+12
-9
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user