diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-10-27 13:13:59 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-10-27 17:24:54 +0000 |
commit | 6796698c9945d87236ffcc939137d0919ef04931 (patch) | |
tree | dd843e7808186887c2959451e34fdd7f42783359 /src/printf.c | |
parent | 106d4bf159a97b573d6479473fa38216fb8bfada (diff) | |
download | coreutils-6796698c9945d87236ffcc939137d0919ef04931.tar.xz |
all: quote string arguments in error messages
These strings are often file names or other user specified
parameters, which can give confusing errors in
the presence of unexpected characters for example.
* cfg.mk (sc_error_quotes): A new syntax check rule.
* src/*.c: Wrap error() string arguments with quote().
* tests/: Adjust accordingly.
* NEWS: Mention the improvement.
Diffstat (limited to 'src/printf.c')
-rw-r--r-- | src/printf.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/printf.c b/src/printf.c index 4260519dc..3e68b995f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -139,15 +139,15 @@ verify_numeric (const char *s, const char *end) { if (errno) { - error (0, errno, "%s", s); + error (0, errno, "%s", quote (s)); exit_status = EXIT_FAILURE; } else if (*end) { if (s == end) - error (0, 0, _("%s: expected a numeric value"), s); + error (0, 0, _("%s: expected a numeric value"), quote (s)); else - error (0, 0, _("%s: value not completely converted"), s); + error (0, 0, _("%s: value not completely converted"), quote (s)); exit_status = EXIT_FAILURE; } } @@ -545,7 +545,7 @@ print_formatted (const char *format, int argc, char **argv) field_width = width; else error (EXIT_FAILURE, 0, _("invalid field width: %s"), - *argv); + quote (*argv)); ++argv; --argc; } @@ -580,7 +580,7 @@ print_formatted (const char *format, int argc, char **argv) } else if (INT_MAX < prec) error (EXIT_FAILURE, 0, _("invalid precision: %s"), - *argv); + quote (*argv)); else precision = prec; ++argv; |