From 6796698c9945d87236ffcc939137d0919ef04931 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Tue, 27 Oct 2015 13:13:59 +0000 Subject: 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. --- src/nl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nl.c') 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; -- cgit v1.2.3-54-g00ecf