]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
all: replace most uses of quotearg_colon() with quote()
authorPádraig Brady <P@draigBrady.com>
Wed, 28 Oct 2015 13:02:31 +0000 (13:02 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 4 Nov 2015 02:03:41 +0000 (02:03 +0000)
Related to commit v8.24-61-g6796698 this provides
more consistent quoting, as quotearg_colon() defaults
to "literal" quoting by default, while quote()
provides appropriate quoting for diagnostics by default.

* gl/modules/randread: Depend on quote module rather than quotearg.
* gl/lib/randread.c: Used quote() not quotearg_colon().
* src/: Likewise.
* src/shred.c: Likewise. Also avoid unnecessary quoting
introducing overhead when wiping names.
* cfg.mk: Relax the matching expression to allow
"qname" variables as used in shred.c to satisfy the check.
* tests/: Adjust accordingly.

23 files changed:
cfg.mk
gl/lib/randread.c
gl/modules/randread
src/chcon.c
src/chmod.c
src/du.c
src/head.c
src/install.c
src/ls.c
src/runcon.c
src/shred.c
src/shuf.c
src/sort.c
src/stat.c
src/tac.c
src/wc.c
tests/du/files0-from-dir.sh
tests/du/files0-from.pl
tests/du/move-dir-while-traversing.sh
tests/misc/shred-passes.sh
tests/misc/sort-files0-from.pl
tests/misc/stat-printf.pl
tests/misc/wc-files0-from.pl

diff --git a/cfg.mk b/cfg.mk
index 86373b8274a8691bce17da0d7dcdd13254963566..208f2ce80d8303af85cd1f44eaf69c2cd8c25b4f 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -182,7 +182,7 @@ sc_prohibit_quotes_notation:
 # on a separate line to the following arguments.
 sc_error_quotes:
        @cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
-         *.c | grep -v quote \
+         *.c | grep -v ', q' \
          && { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
               exit 1; }  \
          || :
index 5efbd4fe43ed35c98dd717dd04af14cddb7acaf3..bd5e38650f936d7ab18a226d7d2dc665220bbcf9 100644 (file)
@@ -28,7 +28,7 @@
 #include <error.h>
 #include <exitfail.h>
 #include <fcntl.h>
-#include <quotearg.h>
+#include <quote.h>
 #include <stdalign.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -126,7 +126,7 @@ randread_error (void const *file_name)
   if (file_name)
     error (exit_failure, errno,
            errno == 0 ? _("%s: end of file") : _("%s: read error"),
-           quotearg_colon (file_name));
+           quote (file_name));
   abort ();
 }
 
index 14af00e7bb7396a5469ee964e8061669f5ce52d4..50e1e0eed1fcdb0c21f04be34254fa0e00fb85bf 100644 (file)
@@ -13,7 +13,7 @@ exitfail
 inline
 fopen-safer
 gettimeofday
-quotearg
+quote
 stdalign
 stdbool
 stdint
index 674d03366a5cc3a0dea645eb307869f27fa59f7d..4f51d70d471025df16b566c9ce76e40d400fa8c9 100644 (file)
@@ -24,7 +24,6 @@
 #include "error.h"
 #include "ignore-value.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "root-dev-ino.h"
 #include "selinux-at.h"
 #include "xfts.h"
@@ -98,7 +97,7 @@ compute_context_from_mask (char const *context, context_t *ret)
   if (!new_context)
     {
       error (0, errno, _("failed to create security context: %s"),
-             quotearg_colon (context));
+             quote (context));
       return 1;
     }
 
index 5c6881c4454ea32821fee4b368eb69c8c7be7bc6..988ba7269b1b6518de0833794883f576cb9c6adb 100644 (file)
@@ -28,7 +28,6 @@
 #include "ignore-value.h"
 #include "modechange.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "root-dev-ino.h"
 #include "xfts.h"
 
@@ -312,7 +311,7 @@ process_file (FTS *fts, FTSENT *ent)
           new_perms[10] = naively_expected_perms[10] = '\0';
           error (0, 0,
                  _("%s: new permissions are %s, not %s"),
-                 quotearg_colon (file_full_name),
+                 quote (file_full_name),
                  new_perms + 1, naively_expected_perms + 1);
           ok = false;
         }
index 0b405f47d4077aec0dfae5315486f0002e0adeca..af6af04f26550f05ce4f8c9269653aa74761c72a 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -37,7 +37,6 @@
 #include "human.h"
 #include "mountlist.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "stat-size.h"
 #include "stat-time.h"
 #include "stdio--.h"
@@ -692,7 +691,7 @@ du_files (char **files, int bit_flags)
               if (errno != 0)
                 {
                   error (0, errno, _("fts_read failed: %s"),
-                         quotearg_colon (fts->fts_path));
+                         quote (fts->fts_path));
                   ok = false;
                 }
 
@@ -883,7 +882,7 @@ main (int argc, char **argv)
           if (add_exclude_file (add_exclude, exclude, optarg,
                                 EXCLUDE_WILDCARDS, '\n'))
             {
-              error (0, errno, "%s", quotearg_colon (optarg));
+              error (0, errno, "%s", quote (optarg));
               ok = false;
             }
           break;
@@ -1069,7 +1068,7 @@ main (int argc, char **argv)
               goto argv_iter_done;
             case AI_ERR_READ:
               error (0, errno, _("%s: read error"),
-                     quotearg_colon (files_from));
+                     quote (files_from));
               ok = false;
               goto argv_iter_done;
             case AI_ERR_MEM:
@@ -1106,7 +1105,7 @@ main (int argc, char **argv)
                  not totally appropriate, since NUL is the separator, not NL,
                  but it might be better than nothing.  */
               unsigned long int file_number = argv_iter_n_args (ai);
-              error (0, 0, "%s:%lu: %s", quotearg_colon (files_from),
+              error (0, 0, "%s:%lu: %s", quote (files_from),
                      file_number, _("invalid zero-length file name"));
             }
           skip_file = true;
index 410cc4f4936b52f2ecab9719d02aa6f546abd178..a77376d102d41eb7af812e5b47ce1e359ceecb8b 100644 (file)
@@ -34,7 +34,6 @@
 #include "error.h"
 #include "full-read.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "safe-read.h"
 #include "stat-size.h"
 #include "xfreopen.h"
@@ -223,7 +222,7 @@ elseek (int fd, off_t offset, int whence, char const *filename)
            _(whence == SEEK_SET
              ? N_("%s: cannot seek to offset %s")
              : N_("%s: cannot seek to relative offset %s")),
-           quotearg_colon (filename),
+           quote (filename),
            offtostr (offset, buf));
 
   return new_offset;
@@ -838,7 +837,7 @@ head (const char *filename, int fd, uintmax_t n_units, bool count_lines,
       if (fstat (fd, &st) != 0)
         {
           error (0, errno, _("cannot fstat %s"),
-                 quotearg_colon (filename));
+                 quote (filename));
           return false;
         }
       if (! presume_input_pipe && usable_st_size (&st))
index bbd67bc02aa113edc5b16fbfb557679c03af6fef..d338cbb29d20d9263960619a1996a7359da3ec01 100644 (file)
@@ -38,7 +38,6 @@
 #include "modechange.h"
 #include "prog-fprintf.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "savewd.h"
 #include "stat-time.h"
 #include "utimens.h"
@@ -374,7 +373,7 @@ setdefaultfilecon (char const *file)
   if (lsetfilecon (file, scontext) < 0 && errno != ENOTSUP)
     error (0, errno,
            _("warning: %s: failed to change context to %s"),
-           quotearg_colon (file), scontext);
+           quote_n (0, file), quote_n (1, scontext));
 
   freecon (scontext);
   return;
index ef372553f181eb14d08f1617b46694dd4a55d920..ef708dfa3ee70d2ae74371f79c7fd804ebc24248 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -2534,7 +2534,7 @@ set_exit_status (bool serious)
 static void
 file_failure (bool serious, char const *message, char const *file)
 {
-  error (0, errno, message, quotearg_colon (file));
+  error (0, errno, message, quote (file));
   set_exit_status (serious);
 }
 
@@ -2601,7 +2601,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
       if (visit_dir (dir_stat.st_dev, dir_stat.st_ino))
         {
           error (0, 0, _("%s: not listing already-listed directory"),
-                 quotearg_colon (name));
+                 quote (name));
           closedir (dirp);
           set_exit_status (true);
           return;
@@ -3109,7 +3109,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
           any_has_acl |= f->acl_type != ACL_T_NONE;
 
           if (err)
-            error (0, errno, "%s", quotearg_colon (absolute_name));
+            error (0, errno, "%s", quote (absolute_name));
         }
 
       if (S_ISLNK (f->stat.st_mode)
index ecb12985a6d72a20fb53d8946c5ea398d777b8fd..d5ec579589bdef8b8107cd38c46770ecd294cecf 100644 (file)
@@ -49,7 +49,6 @@
 #include "system.h"
 #include "error.h"
 #include "quote.h"
-#include "quotearg.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "runcon"
@@ -231,7 +230,7 @@ main (int argc, char **argv)
       con = context_new (cur_context);
       if (!con)
         error (EXIT_FAILURE, errno, _("failed to create security context: %s"),
-               quotearg_colon (cur_context));
+               quote (cur_context));
       if (user && context_user_set (con, user))
         error (EXIT_FAILURE, errno, _("failed to set new user: %s"),
                quote (user));
@@ -248,7 +247,7 @@ main (int argc, char **argv)
 
   if (security_check_context (context_str (con)) < 0)
     error (EXIT_FAILURE, errno, _("invalid context: %s"),
-           quotearg_colon (context_str (con)));
+           quote (context_str (con)));
 
   if (setexeccon (context_str (con)) != 0)
     error (EXIT_FAILURE, errno, _("unable to set security context %s"),
index 6029d37e3fbf3800b183075485cc499977c1e4c5..9c67528816d9c88c260ff4ce3213adea373340f7 100644 (file)
@@ -91,7 +91,6 @@
 #include "fcntl--.h"
 #include "human.h"
 #include "quote.h"
-#include "quotearg.h"          /* For quotearg_colon */
 #include "randint.h"
 #include "randread.h"
 #include "stat-size.h"
@@ -341,7 +340,7 @@ dosync (int fd, char const *qname)
   err = errno;
   if ( ! ignorable_sync_errno (err))
     {
-      error (0, err, _("%s: fdatasync failed"), quote (qname));
+      error (0, err, _("%s: fdatasync failed"), qname);
       errno = err;
       return -1;
     }
@@ -352,7 +351,7 @@ dosync (int fd, char const *qname)
   err = errno;
   if ( ! ignorable_sync_errno (err))
     {
-      error (0, err, _("%s: fsync failed"), quote (qname));
+      error (0, err, _("%s: fsync failed"), qname);
       errno = err;
       return -1;
     }
@@ -470,7 +469,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
 
   if (! dorewind (fd, st))
     {
-      error (0, errno, _("%s: cannot rewind"), quote (qname));
+      error (0, errno, _("%s: cannot rewind"), qname);
       other_error = true;
       goto free_pattern_mem;
     }
@@ -490,8 +489,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
   /* Set position if first status update */
   if (n)
     {
-      error (0, 0, _("%s: pass %lu/%lu (%s)..."),
-             quote (qname), k, n, pass_string);
+      error (0, 0, _("%s: pass %lu/%lu (%s)..."), qname, k, n, pass_string);
       thresh = time (NULL) + VERBOSE_UPDATE;
       previous_human_offset = "";
     }
@@ -543,7 +541,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
                       continue;
                     }
                   error (0, errnum, _("%s: error writing at offset %s"),
-                         quote (qname), umaxtostr (offset + soff, buf));
+                         qname, umaxtostr (offset + soff, buf));
 
                   /* 'shred' is often used on bad media, before throwing it
                      out.  Thus, it shouldn't give up on bad blocks.  This
@@ -563,7 +561,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
                           write_error = true;
                           continue;
                         }
-                      error (0, errno, _("%s: lseek failed"), quote (qname));
+                      error (0, errno, _("%s: lseek failed"), qname);
                     }
                   other_error = true;
                   goto free_pattern_mem;
@@ -575,7 +573,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
 
       if (OFF_T_MAX - offset < soff)
         {
-          error (0, 0, _("%s: file too large"), quote (qname));
+          error (0, 0, _("%s: file too large"), qname);
           other_error = true;
           goto free_pattern_mem;
         }
@@ -600,7 +598,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
             {
               if (! known (size))
                 error (0, 0, _("%s: pass %lu/%lu (%s)...%s"),
-                       quote (qname), k, n, pass_string, human_offset);
+                       qname, k, n, pass_string, human_offset);
               else
                 {
                   uintmax_t off = offset;
@@ -616,8 +614,8 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
                   if (done)
                     human_offset = human_size;
                   error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"),
-                         quote (qname), k, n, pass_string, human_offset,
-                         human_size, percent);
+                         qname, k, n, pass_string, human_offset, human_size,
+                         percent);
                 }
 
               strcpy (previous_offset_buf, human_offset);
@@ -874,7 +872,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
 
   if (fstat (fd, &st))
     {
-      error (0, errno, _("%s: fstat failed"), quote (qname));
+      error (0, errno, _("%s: fstat failed"), qname);
       return false;
     }
 
@@ -885,12 +883,12 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
       || S_ISFIFO (st.st_mode)
       || S_ISSOCK (st.st_mode))
     {
-      error (0, 0, _("%s: invalid file type"), quote (qname));
+      error (0, 0, _("%s: invalid file type"), qname);
       return false;
     }
   else if (S_ISREG (st.st_mode) && st.st_size < 0)
     {
-      error (0, 0, _("%s: file has negative size"), quote (qname));
+      error (0, 0, _("%s: file has negative size"), qname);
       return false;
     }
 
@@ -984,7 +982,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
   if (flags->remove_file && ftruncate (fd, 0) != 0
       && S_ISREG (st.st_mode))
     {
-      error (0, errno, _("%s: error truncating"), quote (qname));
+      error (0, errno, _("%s: error truncating"), qname);
       ok = false;
       goto wipefd_out;
     }
@@ -1004,13 +1002,12 @@ wipefd (int fd, char const *qname, struct randint_source *s,
 
   if (fd_flags < 0)
     {
-      error (0, errno, _("%s: fcntl failed"), quote (qname));
+      error (0, errno, _("%s: fcntl failed"), qname);
       return false;
     }
   if (fd_flags & O_APPEND)
     {
-      error (0, 0, _("%s: cannot shred append-only file descriptor"),
-             quote (qname));
+      error (0, 0, _("%s: cannot shred append-only file descriptor"), qname);
       return false;
     }
   return do_wipefd (fd, qname, s, flags);
@@ -1085,7 +1082,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
   char *base = last_component (newname);
   size_t len = base_len (base);
   char *dir = dir_name (newname);
-  char *qdir = xstrdup (quotearg_colon (dir));
+  char *qdir = xstrdup (quote (dir));
   bool first = true;
   bool ok = true;
   int dir_fd = -1;
@@ -1094,7 +1091,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
     dir_fd = open (dir, O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
 
   if (flags->verbose)
-    error (0, 0, _("%s: removing"), quote (qoldname));
+    error (0, 0, _("%s: removing"), qoldname);
 
   while ((flags->remove_file != remove_unlink) && len)
     {
@@ -1119,7 +1116,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
                        */
                       char const *old = (first ? qoldname : oldname);
                       error (0, 0, _("%s: renamed to %s"),
-                             quote_n (0, old), quote_n (1, newname));
+                             old, newname);
                       first = false;
                     }
                   memcpy (oldname + (base - newname), base, len + 1);
@@ -1141,18 +1138,18 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags)
     }
   if (unlink (oldname) != 0)
     {
-      error (0, errno, _("%s: failed to remove"), quote (qoldname));
+      error (0, errno, _("%s: failed to remove"), qoldname);
       ok = false;
     }
   else if (flags->verbose)
-    error (0, 0, _("%s: removed"), quote (qoldname));
+    error (0, 0, _("%s: removed"), qoldname);
   if (0 <= dir_fd)
     {
       if (dosync (dir_fd, qdir) != 0)
         ok = false;
       if (close (dir_fd) != 0)
         {
-          error (0, errno, _("%s: failed to close"), quote (qdir));
+          error (0, errno, _("%s: failed to close"), qdir);
           ok = false;
         }
     }
@@ -1188,14 +1185,14 @@ wipefile (char *name, char const *qname,
     fd = open (name, O_WRONLY | O_NOCTTY | O_BINARY);
   if (fd < 0)
     {
-      error (0, errno, _("%s: failed to open for writing"), quote (qname));
+      error (0, errno, _("%s: failed to open for writing"), qname);
       return false;
     }
 
   ok = do_wipefd (fd, qname, s, flags);
   if (close (fd) != 0)
     {
-      error (0, errno, _("%s: failed to close"), quote (qname));
+      error (0, errno, _("%s: failed to close"), qname);
       ok = false;
     }
   if (ok && flags->remove_file)
@@ -1305,12 +1302,12 @@ main (int argc, char **argv)
 
   randint_source = randint_all_new (random_source, SIZE_MAX);
   if (! randint_source)
-    error (EXIT_FAILURE, errno, "%s", quotearg_colon (random_source));
+    error (EXIT_FAILURE, errno, "%s", quote (random_source));
   atexit (clear_random_data);
 
   for (i = 0; i < n_files; i++)
     {
-      char *qname = xstrdup (quotearg_colon (file[i]));
+      char *qname = xstrdup (quote (file[i]));
       if (STREQ (file[i], "-"))
         {
           ok &= wipefd (STDOUT_FILENO, qname, randint_source, &flags);
index 040b00028a970f9b0f1644e5a6e6036bc8aff1a7..d7b5a3521f5c3e9301ff2139837ff1d372b82fcd 100644 (file)
@@ -27,7 +27,6 @@
 #include "getopt.h"
 #include "linebuffer.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "randint.h"
 #include "randperm.h"
 #include "read-file.h"
@@ -545,7 +544,7 @@ main (int argc, char **argv)
                                      ? SIZE_MAX
                                      : randperm_bound (head_lines, n_lines)));
   if (! randint_source)
-    error (EXIT_FAILURE, errno, "%s", quotearg_colon (random_source));
+    error (EXIT_FAILURE, errno, "%s", quote (random_source));
 
   if (use_reservoir_sampling)
     {
@@ -567,7 +566,7 @@ main (int argc, char **argv)
     permutation = randperm_new (randint_source, head_lines, n_lines);
 
   if (outfile && ! freopen (outfile, "w", stdout))
-    error (EXIT_FAILURE, errno, "%s", quotearg_colon (outfile));
+    error (EXIT_FAILURE, errno, "%s", quote (outfile));
 
   /* Generate output according to requested method */
   if (repeat)
index 09231c44b304e86b26aed2535433b165cc698707..3e741027c8f6ee4ca6c205c5de9b19a91660fc57 100644 (file)
@@ -4612,7 +4612,7 @@ main (int argc, char **argv)
                   unsigned long int file_number = i + 1;
                   error (SORT_FAILURE, 0,
                          _("%s:%lu: invalid zero-length file name"),
-                         quotearg_colon (files_from), file_number);
+                         quote (files_from), file_number);
                 }
             }
         }
index 680a598f078d06d8868b7363e907f8fd6100f0a5..a8a8c9d64f76889410f81a2dc2055ea70083717a 100644 (file)
@@ -66,7 +66,6 @@
 #include "getopt.h"
 #include "mountlist.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "stat-size.h"
 #include "stat-time.h"
 #include "strftime.h"
@@ -1188,7 +1187,7 @@ print_it (char const *format, int fd, char const *filename,
                     dest[len + 1] = *fmt_char;
                     dest[len + 2] = '\0';
                     error (EXIT_FAILURE, 0, _("%s: invalid directive"),
-                           quotearg_colon (dest));
+                           quote (dest));
                   }
                 putchar ('%');
                 break;
index 1029de63b472ebc4855d3d812f27730f15dbf6bf..a260b7bada30e5657d99883968805536d372a06b 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -46,7 +46,6 @@ tac -r -s '.\|
 #include "error.h"
 #include "filenamecat.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "safe-read.h"
 #include "stdlib--.h"
 #include "xfreopen.h"
@@ -221,7 +220,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
     {
       file_pos -= remainder;
       if (lseek (input_fd, file_pos, SEEK_SET) < 0)
-        error (0, errno, _("%s: seek failed"), quotearg_colon (file));
+        error (0, errno, _("%s: seek failed"), quote (file));
     }
 
   /* Scan backward, looking for end of file.  This caters to proc-like
@@ -231,7 +230,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
     {
       off_t rsize = read_size;
       if (lseek (input_fd, -rsize, SEEK_CUR) < 0)
-        error (0, errno, _("%s: seek failed"), quotearg_colon (file));
+        error (0, errno, _("%s: seek failed"), quote (file));
       file_pos -= read_size;
     }
 
@@ -249,7 +248,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
 
   if (saved_record_size == SAFE_READ_ERROR)
     {
-      error (0, errno, _("%s: read error"), quotearg_colon (file));
+      error (0, errno, _("%s: read error"), quote (file));
       return false;
     }
 
@@ -341,7 +340,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
               file_pos = 0;
             }
           if (lseek (input_fd, file_pos, SEEK_SET) < 0)
-            error (0, errno, _("%s: seek failed"), quotearg_colon (file));
+            error (0, errno, _("%s: seek failed"), quote (file));
 
           /* Shift the pending record data right to make room for the new.
              The source and destination regions probably overlap.  */
@@ -355,7 +354,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
 
           if (safe_read (input_fd, G_buffer, read_size) != read_size)
             {
-              error (0, errno, _("%s: read error"), quotearg_colon (file));
+              error (0, errno, _("%s: read error"), quote (file));
               return false;
             }
         }
@@ -512,13 +511,13 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file)
         break;
       if (bytes_read == SAFE_READ_ERROR)
         {
-          error (0, errno, _("%s: read error"), quotearg_colon (file));
+          error (0, errno, _("%s: read error"), quote (file));
           goto Fail;
         }
 
       if (fwrite (G_buffer, 1, bytes_read, fp) != bytes_read)
         {
-          error (0, errno, _("%s: write error"), quotearg_colon (file_name));
+          error (0, errno, _("%s: write error"), quote (file_name));
           goto Fail;
         }
 
@@ -530,7 +529,7 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file)
 
   if (fflush (fp) != 0)
     {
-      error (0, errno, _("%s: write error"), quotearg_colon (file_name));
+      error (0, errno, _("%s: write error"), quote (file_name));
       goto Fail;
     }
 
@@ -598,7 +597,7 @@ tac_file (const char *filename)
 
   if (!is_stdin && close (fd) != 0)
     {
-      error (0, errno, _("%s: read error"), quotearg_colon (filename));
+      error (0, errno, _("%s: read error"), quote (filename));
       ok = false;
     }
   return ok;
index fc66dfc73568a12c0ef442274f6854cc9a65eda1..30a08926f5eee82aace08188af8a6278a6ba2b41 100644 (file)
--- a/src/wc.c
+++ b/src/wc.c
@@ -33,7 +33,6 @@
 #include "mbchar.h"
 #include "physmem.h"
 #include "quote.h"
-#include "quotearg.h"
 #include "readtokens0.h"
 #include "safe-read.h"
 #include "stat-size.h"
@@ -765,7 +764,7 @@ main (int argc, char **argv)
               goto argv_iter_done;
             case AI_ERR_READ:
               error (0, errno, _("%s: read error"),
-                     quotearg_colon (files_from));
+                     quote (files_from));
               ok = false;
               goto argv_iter_done;
             case AI_ERR_MEM:
@@ -798,7 +797,7 @@ main (int argc, char **argv)
                  not totally appropriate, since NUL is the separator, not NL,
                  but it might be better than nothing.  */
               unsigned long int file_number = argv_iter_n_args (ai);
-              error (0, 0, "%s:%lu: %s", quotearg_colon (files_from),
+              error (0, 0, "%s:%lu: %s", quote (files_from),
                      file_number, _("invalid zero-length file name"));
             }
           skip_file = true;
index 2f55c4ed638d7517646becf550ca1695f3b34227..4d7e90cf5d9999f10d91908a1d6dd01934dee01a 100755 (executable)
@@ -29,10 +29,10 @@ cat dir > /dev/null && skip_ "cat dir/ succeeds"
 
 for prog in du wc; do
   $prog --files0-from=dir > /dev/null 2>err && fail=1
-  printf "$prog: dir:\n" > exp || fail=1
+  printf "$prog: 'dir':\n" > exp || fail=1
   # The diagnostic string is usually "Is a directory" (ENOTDIR),
   # but accept a different string or errno value.
-  sed 's/dir:.*/dir:/' err > k; mv k err
+  sed "s/'dir':.*/'dir':/" err > k; mv k err
   compare exp err || fail=1
 done
 
index 3854059f03e63322967e3cd7640a1de7ac246eed..f0177a2d09c3b5b9dfe2051042b32f2ca111c2d2 100755 (executable)
@@ -53,12 +53,12 @@ my @Tests =
 
    # one NUL
    ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
 
    # two NULs
    ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"
-          . "$prog: -:2: invalid zero-length file name\n"}],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"
+          . "$prog: '-':2: invalid zero-length file name\n"}],
 
    # one file name, no NUL
    ['1', '--files0-from=-', '<',
@@ -84,7 +84,7 @@ my @Tests =
    ['zero-len', '--files0-from=-', '<',
     {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
     {OUT=>"0\tg\n"}, {OUT_SUBST=>'s/^\d+/0/'},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>1} ],
   );
 
 my $save_temps = $ENV{DEBUG};
index 67bb34580742f67bacdb2acbf965f963b41aea59..33db58e44fadadff6368b5d56815eeff01780907 100755 (executable)
@@ -92,7 +92,7 @@ du -a $t d2 2> err
 test $? = 1 || fail=1
 
 # check for the new diagnostic
-printf "du: fts_read failed: $t/3/a/b: No such file or directory\n" > exp \
+printf "du: fts_read failed: '$t/3/a/b': No such file or directory\n" > exp \
   || fail=1
 compare exp err || fail=1
 
index c19cc7655374389eb36155df72e74885c662182b..ddf788b05ee3852e14f29be9d3da84cf175c877d 100755 (executable)
@@ -28,7 +28,7 @@ shred: 'f': pass 1/3 (random)...
 shred: 'f': pass 2/3 (random)...
 shred: 'f': pass 3/3 (random)...
 shred: 'f': removing
-shred: 'f': renamed to '0'
+shred: 'f': renamed to 0
 shred: 'f': removed" > exp || framework_failure_
 
 shred -v -u f 2>out || fail=1
@@ -40,7 +40,7 @@ compare exp out || fail=1
 touch f || framework_failure_
 echo "\
 shred: 'f': removing
-shred: 'f': renamed to '0'
+shred: 'f': renamed to 0
 shred: 'f': removed" > exp || framework_failure_
 
 shred -v -u f 2>out || fail=1
@@ -73,7 +73,7 @@ shred: 'f': pass 18/20 (eeeeee)...
 shred: 'f': pass 19/20 (333333)...
 shred: 'f': pass 20/20 (random)...
 shred: 'f': removing
-shred: 'f': renamed to '0'
+shred: 'f': renamed to 0
 shred: 'f': removed" > exp || framework_failure_
 
 shred -v -u -n20 --random-source=Us f 2>out || fail=1
index 63c5bb3e49827197f862f146ef610bd82cb9b8c0..6773309d17d121cf8ece1a17b509aad72ea0befa 100755 (executable)
@@ -55,14 +55,14 @@ my @Tests =
 
    # one NUL
    ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>2},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
 
    # two NULs
    # Note that the behavior here differs from 'wc' in that the
    # first zero-length file name is treated as fatal, so there
    # is only one line of diagnostic output.
    ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>2},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
 
    # one file name, no NUL
    ['1', '--files0-from=-', '<',
@@ -86,7 +86,7 @@ my @Tests =
    # should be no output on STDOUT.
    ['zero-len', '--files0-from=-', '<',
     {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>2} ],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>2} ],
   );
 
 my $save_temps = $ENV{DEBUG};
index 967eef7d221f2290d0e759c68faaef4832503c5a..cb148b615d2b1cb656a3556a77566291da4a0c1c 100755 (executable)
@@ -52,9 +52,9 @@ my @Tests =
          {ERR=>"$prog: warning: backslash at end of format\n"}],
 
      ['err-1', "--printf=%9% .",       {EXIT => 1},
-         {ERR=>"$prog: %9%: invalid directive\n"}],
+         {ERR=>"$prog: '%9%': invalid directive\n"}],
      ['err-2', "--printf=%9 .",        {EXIT => 1},
-         {ERR=>"$prog: %9: invalid directive\n"}],
+         {ERR=>"$prog: '%9': invalid directive\n"}],
     );
 
 my $save_temps = $ENV{DEBUG};
index cae3fc2258f1bd6b53190afaf1c79b6a0da258eb..519587be619a2da2f746d7a2fedd7bc62a3d3198 100755 (executable)
@@ -53,13 +53,13 @@ my @Tests =
 
    # one NUL
    ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}],
 
    # two NULs
    ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1},
     {OUT=>"0 0 0 total\n"},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"
-          . "$prog: -:2: invalid zero-length file name\n"}],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"
+          . "$prog: '-':2: invalid zero-length file name\n"}],
 
    # one file name, no NUL
    ['1', '--files0-from=-', '<',
@@ -83,7 +83,7 @@ my @Tests =
    ['zero-len', '--files0-from=-', '<',
     {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
     {OUT=>"0 0 0 g\n0 0 0 total\n"},
-    {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ],
+    {ERR => "$prog: '-':1: invalid zero-length file name\n"}, {EXIT=>1} ],
   );
 
 my $save_temps = $ENV{DEBUG};