summaryrefslogtreecommitdiff
path: root/src/nl.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/nl.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/nl.c')
-rw-r--r--src/nl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nl.c b/src/nl.c
index 1132af398..f431d9839 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -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;