From 08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sun, 1 Nov 2015 18:53:26 +0000 Subject: all: avoid quoting file names when possible Quote file names using the "shell-escape" or "shell-escape-always" methods, which quote as appropriate for most shells, and better support copy and paste of presented names. The "always" variant is used when the file name is embedded in an error message with surrounding spaces. * cfg.mk (sc_error_shell_quotes): A new syntax check rule to suggest quotef() where appropriate. (sc_error_shell_always_quotes): Likewise for quoteaf(). * src/system.h (quotef): A new define to apply shell quoting when needed. I.E. when shell character or ':' is present. (quoteaf): Likewise, but always quote. * src/*.c: Use quotef() and quoteaf() rather than quote() where appropriate. * tests/: Adjust accordingly. --- src/tsort.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/tsort.c') diff --git a/src/tsort.c b/src/tsort.c index dc9bed5e9..9a8498001 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -30,9 +30,9 @@ #include "long-options.h" #include "error.h" #include "fadvise.h" -#include "quote.h" #include "readtokens.h" #include "stdio--.h" +#include "quote.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "tsort" @@ -445,7 +445,7 @@ tsort (const char *file) root = new_item (NULL); if (!is_stdin && ! freopen (file, "r", stdin)) - error (EXIT_FAILURE, errno, "%s", quote (file)); + error (EXIT_FAILURE, errno, "%s", quotef (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"), - quote (file)); + quotef (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:"), quote (file)); + error (0, 0, _("%s: input contains a loop:"), quotef (file)); ok = false; /* Print the loop and remove a relation to break it. */ @@ -532,7 +532,7 @@ tsort (const char *file) if (fclose (stdin) != 0) error (EXIT_FAILURE, errno, "%s", - is_stdin ? _("standard input") : quote (file)); + is_stdin ? _("standard input") : quotef (file)); return ok; } -- cgit v1.2.3-70-g09d2