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/tsort.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/tsort.c') diff --git a/src/tsort.c b/src/tsort.c index 0533451da..dc9bed5e9 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -351,7 +351,7 @@ detect_loop (struct item *k) { struct item *tmp = loop->qlink; - error (0, 0, "%s", loop->str); + error (0, 0, "%s", (loop->str)); /* Until we encounter K again. */ if (loop == k) @@ -445,7 +445,7 @@ tsort (const char *file) root = new_item (NULL); if (!is_stdin && ! freopen (file, "r", stdin)) - error (EXIT_FAILURE, errno, "%s", file); + error (EXIT_FAILURE, errno, "%s", quote (file)); fadvise (stdin, FADVISE_SEQUENTIAL); @@ -473,7 +473,7 @@ tsort (const char *file) if (k != NULL) error (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"), - file); + quote (file)); /* T1. Initialize (N <- n). */ walk_tree (root, count_items); @@ -518,7 +518,7 @@ tsort (const char *file) if (n_strings > 0) { /* The input contains a loop. */ - error (0, 0, _("%s: input contains a loop:"), file); + error (0, 0, _("%s: input contains a loop:"), quote (file)); ok = false; /* Print the loop and remove a relation to break it. */ -- cgit v1.2.3-70-g09d2