summaryrefslogtreecommitdiff
path: root/src/od.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-10-27 13:13:59 +0000
committerPádraig Brady <P@draigBrady.com>2015-10-27 17:24:54 +0000
commit6796698c9945d87236ffcc939137d0919ef04931 (patch)
treedd843e7808186887c2959451e34fdd7f42783359 /src/od.c
parent106d4bf159a97b573d6479473fa38216fb8bfada (diff)
downloadcoreutils-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/od.c')
-rw-r--r--src/od.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/od.c b/src/od.c
index 0ca3ca787..643fb3878 100644
--- a/src/od.c
+++ b/src/od.c
@@ -921,7 +921,7 @@ open_next_file (void)
in_stream = fopen (input_filename, (O_BINARY ? "rb" : "r"));
if (in_stream == NULL)
{
- error (0, errno, "%s", input_filename);
+ error (0, errno, "%s", quote (input_filename));
ok = false;
}
}
@@ -950,14 +950,14 @@ check_and_close (int in_errno)
{
if (ferror (in_stream))
{
- error (0, in_errno, _("%s: read error"), input_filename);
+ error (0, in_errno, _("%s: read error"), quote (input_filename));
if (! STREQ (file_list[-1], "-"))
fclose (in_stream);
ok = false;
}
else if (! STREQ (file_list[-1], "-") && fclose (in_stream) != 0)
{
- error (0, errno, "%s", input_filename);
+ error (0, errno, "%s", quote (input_filename));
ok = false;
}
@@ -1092,7 +1092,7 @@ skip (uintmax_t n_skip)
else /* cannot fstat() file */
{
- error (0, errno, "%s", input_filename);
+ error (0, errno, "%s", quote (input_filename));
ok = false;
}
@@ -1692,7 +1692,7 @@ main (int argc, char **argv)
/* The minimum string length may be no larger than SIZE_MAX,
since we may allocate a buffer of this size. */
if (SIZE_MAX < tmp)
- error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
+ error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
string_min = tmp;
}
@@ -1773,7 +1773,7 @@ main (int argc, char **argv)
if (s_err != LONGINT_OK)
xstrtol_fatal (s_err, oi, c, long_options, optarg);
if (SIZE_MAX < w_tmp)
- error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
+ error (EXIT_FAILURE, 0, _("%s is too large"), quote (optarg));
desired_width = w_tmp;
}
break;