summaryrefslogtreecommitdiff
path: root/src/cksum.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-01 18:53:26 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-04 23:30:14 +0000
commit08e8fd7e38f2dae7c69c54eb22d508b6517e66e5 (patch)
tree63d021e305cd93bea445f9484fe8b3446dda2c3d /src/cksum.c
parent1e8f9afac53a628dbc64e62bea53eb2da29c47fa (diff)
downloadcoreutils-08e8fd7e38f2dae7c69c54eb22d508b6517e66e5.tar.xz
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.
Diffstat (limited to 'src/cksum.c')
-rw-r--r--src/cksum.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/cksum.c b/src/cksum.c
index 2a19c678a..ef51010b2 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -44,7 +44,6 @@
#include <stdint.h>
#include "system.h"
#include "fadvise.h"
-#include "quote.h"
#include "xfreopen.h"
#ifdef CRCTAB
@@ -202,7 +201,7 @@ cksum (const char *file, bool print_name)
fp = fopen (file, (O_BINARY ? "rb" : "r"));
if (fp == NULL)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}
}
@@ -214,7 +213,7 @@ cksum (const char *file, bool print_name)
unsigned char *cp = buf;
if (length + bytes_read < length)
- error (EXIT_FAILURE, 0, _("%s: file too long"), quote (file));
+ error (EXIT_FAILURE, 0, _("%s: file too long"), quotef (file));
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF];
@@ -224,7 +223,7 @@ cksum (const char *file, bool print_name)
if (ferror (fp))
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
if (!STREQ (file, "-"))
fclose (fp);
return false;
@@ -232,7 +231,7 @@ cksum (const char *file, bool print_name)
if (!STREQ (file, "-") && fclose (fp) == EOF)
{
- error (0, errno, "%s", quote (file));
+ error (0, errno, "%s", quotef (file));
return false;
}