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/wc.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/wc.c')
-rw-r--r-- | src/wc.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -259,7 +259,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) { if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); ok = false; break; } @@ -275,7 +275,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) { if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); ok = false; break; } @@ -343,7 +343,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) # endif if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); ok = false; break; } @@ -464,7 +464,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) const char *p = buf; if (bytes_read == SAFE_READ_ERROR) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); ok = false; break; } @@ -541,7 +541,7 @@ wc_file (char const *file, struct fstatus *fstatus) int fd = open (file, O_RDONLY | O_BINARY); if (fd == -1) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); return false; } else @@ -549,7 +549,7 @@ wc_file (char const *file, struct fstatus *fstatus) bool ok = wc (fd, file, fstatus, 0); if (close (fd) != 0) { - error (0, errno, "%s", file); + error (0, errno, "%s", quote (file)); return false; } return ok; |