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/nl.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/nl.c')
-rw-r--r-- | src/nl.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -255,7 +255,7 @@ build_type_arg (char const **typep, RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES; errmsg = re_compile_pattern (optarg, strlen (optarg), regexp); if (errmsg) - error (EXIT_FAILURE, 0, "%s", errmsg); + error (EXIT_FAILURE, 0, "%s", (errmsg)); break; default: rval = false; @@ -426,7 +426,7 @@ nl_file (char const *file) stream = fopen (file, "r"); if (stream == NULL) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); return false; } } @@ -437,14 +437,14 @@ nl_file (char const *file) if (ferror (stream)) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); return false; } if (STREQ (file, "-")) clearerr (stream); /* Also clear EOF. */ else if (fclose (stream) == EOF) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); return false; } return true; |