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/fold.c | |
parent | 106d4bf159a97b573d6479473fa38216fb8bfada (diff) | |
download | coreutils-6796698c9945d87236ffcc939137d0919ef04931.tar.gz |
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/fold.c')
-rw-r--r-- | src/fold.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fold.c b/src/fold.c index 0955c09d9..2f917f400 100644 --- a/src/fold.c +++ b/src/fold.c @@ -25,6 +25,7 @@ #include "system.h" #include "error.h" #include "fadvise.h" +#include "quote.h" #include "xdectoint.h" #define TAB_WIDTH 8 @@ -136,7 +137,7 @@ fold_file (char const *filename, size_t width) if (istream == NULL) { - error (0, errno, "%s", filename); + error (0, errno, "%s", quote (filename)); return false; } @@ -221,14 +222,14 @@ fold_file (char const *filename, size_t width) if (ferror (istream)) { - error (0, saved_errno, "%s", filename); + error (0, saved_errno, "%s", quote (filename)); if (!STREQ (filename, "-")) fclose (istream); return false; } if (!STREQ (filename, "-") && fclose (istream) == EOF) { - error (0, errno, "%s", filename); + error (0, errno, "%s", quote (filename)); return false; } |