Don't embed `this'-style quotes in format strings.
authorJim Meyering <jim@meyering.net>
Thu, 16 Jun 2005 21:33:43 +0000 (21:33 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 16 Jun 2005 21:33:43 +0000 (21:33 +0000)
Rather than this: error (..., "...`%s'...", arg);
do this:          error (..., "...%s...", quote (arg));

src/csplit.c
src/date.c
src/hostname.c
src/join.c
src/ptx.c
src/seq.c
src/sort.c
src/split.c
src/tail.c

index d49e30e..d7e2f20 100644 (file)
@@ -710,8 +710,8 @@ handle_line_error (const struct control *p, uintmax_t repetition)
 {
   char buf[INT_BUFSIZE_BOUND (uintmax_t)];
 
-  fprintf (stderr, _("%s: `%s': line number out of range"),
-          program_name, umaxtostr (p->lines_required, buf));
+  fprintf (stderr, _("%s: %s: line number out of range"),
+          program_name, quote (umaxtostr (p->lines_required, buf)));
   if (repetition)
     fprintf (stderr, _(" on repetition %s\n"), umaxtostr (repetition, buf));
   else
@@ -756,8 +756,8 @@ static void regexp_error (struct control *, uintmax_t, bool) ATTRIBUTE_NORETURN;
 static void
 regexp_error (struct control *p, uintmax_t repetition, bool ignore)
 {
-  fprintf (stderr, _("%s: `%s': match not found"),
-          program_name, global_argv[p->argnum]);
+  fprintf (stderr, _("%s: %s: match not found"),
+          program_name, quote (global_argv[p->argnum]));
 
   if (repetition)
     {
@@ -985,7 +985,7 @@ close_output_file (void)
     {
       if (ferror (output_stream))
        {
-         error (0, 0, _("write error for `%s'"), output_filename);
+         error (0, 0, _("write error for %s"), quote (output_filename));
          output_stream = NULL;
          cleanup_fatal ();
        }
@@ -1172,14 +1172,14 @@ parse_patterns (int argc, int start, char **argv)
            {
              char buf[INT_BUFSIZE_BOUND (uintmax_t)];
              error (EXIT_FAILURE, 0,
-              _("line number `%s' is smaller than preceding line number, %s"),
-                    argv[i], umaxtostr (last_val, buf));
+              _("line number %s is smaller than preceding line number, %s"),
+                    quote (argv[i]), umaxtostr (last_val, buf));
            }
 
          if (val == last_val)
            error (0, 0,
-          _("warning: line number `%s' is the same as preceding line number"),
-                  argv[i]);
+          _("warning: line number %s is the same as preceding line number"),
+                  quote (argv[i]));
 
          last_val = val;
 
index c1136fa..b2af224 100644 (file)
@@ -273,7 +273,7 @@ batch_convert (const char *input_filename, const char *format)
        {
          if (line[line_length - 1] == '\n')
            line[line_length - 1] = '\0';
-         error (0, 0, _("invalid date `%s'"), line);
+         error (0, 0, _("invalid date %s"), quote (line));
          ok = false;
        }
       else
@@ -384,10 +384,10 @@ main (int argc, char **argv)
       && n_args == 1 && argv[optind][0] != '+')
     {
       error (0, 0, _("\
-the argument `%s' lacks a leading `+';\n\
+the argument %s lacks a leading `+';\n\
 When using an option to specify date(s), any non-option\n\
 argument must be a format string beginning with `+'."),
-            argv[optind]);
+            quote (argv[optind]));
       usage (EXIT_FAILURE);
     }
 
@@ -452,7 +452,7 @@ argument must be a format string beginning with `+'."),
        }
 
       if (! valid_date)
-       error (EXIT_FAILURE, 0, _("invalid date `%s'"), datestr);
+       error (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr));
 
       if (set_date)
        {
index 082c891..0abe64e 100644 (file)
@@ -100,7 +100,7 @@ main (int argc, char **argv)
       /* Set hostname to operand.  */
       char const *name = argv[optind];
       if (sethostname (name, strlen (name)) != 0)
-       error (EXIT_FAILURE, errno, _("cannot set name to `%s'"), name);
+       error (EXIT_FAILURE, errno, _("cannot set name to %s"), quote (name));
 #else
       error (EXIT_FAILURE, 0,
             _("cannot set hostname; this system lacks the functionality"));
index 8f44612..979186c 100644 (file)
@@ -879,8 +879,8 @@ main (int argc, char **argv)
                if (STREQ (optarg, "\\0"))
                  newtab = '\0';
                else
-                 error (EXIT_FAILURE, 0, _("multi-character tab `%s'"),
-                        optarg);
+                 error (EXIT_FAILURE, 0, _("multi-character tab %s"),
+                        quote (optarg));
              }
            if (0 <= tab && tab != newtab)
              error (EXIT_FAILURE, 0, _("incompatible tabs"));
index f53a662..a01175d 100644 (file)
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -407,7 +407,7 @@ alloc_and_compile_regex (const char *string)
 
   message = re_compile_pattern (string, (int) strlen (string), pattern);
   if (message)
-    error (EXIT_FAILURE, 0, _("%s (for regexp `%s')"), message, string);
+    error (EXIT_FAILURE, 0, _("%s (for regexp %s)"), message, quote (string));
 
   /* The fastmap should be compiled before `re_match'.  The following
      call is not mandatory, because `re_search' is always called sooner,
index 2d1970b..e8bc1ed 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -376,7 +376,7 @@ main (int argc, char **argv)
 
   if (format_str && !valid_format (format_str))
     {
-      error (0, 0, _("invalid format string: `%s'"), format_str);
+      error (0, 0, _("invalid format string: %s"), quote (format_str));
       usage (EXIT_FAILURE);
     }
 
index 7ba36ca..2b583d2 100644 (file)
@@ -1985,8 +1985,8 @@ static void badfieldspec (char const *, char const *)
 static void
 badfieldspec (char const *spec, char const *msgid)
 {
-  error (SORT_FAILURE, 0, _("%s: invalid field specification `%s'"),
-        _(msgid), spec);
+  error (SORT_FAILURE, 0, _("%s: invalid field specification %s"),
+        _(msgid), quote (spec));
   abort ();
 }
 
@@ -2018,8 +2018,8 @@ parse_field_count (char const *string, size_t *val, char const *msgid)
 
     case LONGINT_INVALID:
       if (msgid)
-       error (SORT_FAILURE, 0, _("%s: invalid count at start of `%s'"),
-              _(msgid), string);
+       error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
+              _(msgid), quote (string));
       return NULL;
     }
 
@@ -2360,8 +2360,8 @@ main (int argc, char **argv)
                       "multi-character tab" instead of "multibyte tab", so
                       that the diagnostic's wording does not need to be
                       changed once multibyte characters are supported.  */
-                   error (SORT_FAILURE, 0, _("multi-character tab `%s'"),
-                          optarg);
+                   error (SORT_FAILURE, 0, _("multi-character tab %s"),
+                          quote (optarg));
                  }
              }
            if (tab != TAB_DEFAULT && tab != newtab)
index 631fd04..95cb05c 100644 (file)
@@ -211,7 +211,7 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
 
       next_file_name ();
       if (verbose)
-       fprintf (stderr, _("creating file `%s'\n"), outfile);
+       fprintf (stderr, _("creating file %s\n"), quote (outfile));
       output_desc = fd_safer (open (outfile,
                                    O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
                                    (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
index 522cadf..104e9f8 100644 (file)
@@ -877,8 +877,8 @@ recheck (struct File_spec *f, bool blocking)
                 unreadable (perms), and later becomes readable again and can
                 be seen to be the same file (dev/ino).  Otherwise, tail prints
                 the entire contents of the file when it becomes readable.  */
-             error (0, f->errnum, _("`%s' has become inaccessible"),
-                    pretty_name (f));
+             error (0, f->errnum, _("%s has become inaccessible"),
+                    quote (pretty_name (f)));
            }
          else
            {
@@ -894,9 +894,9 @@ recheck (struct File_spec *f, bool blocking)
     {
       ok = false;
       f->errnum = -1;
-      error (0, 0, _("`%s' has been replaced with an untailable file;\
+      error (0, 0, _("%s has been replaced with an untailable file;\
  giving up on this name"),
-            pretty_name (f));
+            quote (pretty_name (f)));
       f->ignore = true;
     }
   else
@@ -915,7 +915,7 @@ recheck (struct File_spec *f, bool blocking)
     {
       new_file = true;
       assert (f->fd == -1);
-      error (0, 0, _("`%s' has become accessible"), pretty_name (f));
+      error (0, 0, _("%s has become accessible"), quote (pretty_name (f)));
     }
   else if (f->ino != new_stats.st_ino || f->dev != new_stats.st_dev)
     {
@@ -923,8 +923,8 @@ recheck (struct File_spec *f, bool blocking)
       if (f->fd == -1)
        {
          error (0, 0,
-                _("`%s' has appeared;  following end of new file"),
-                pretty_name (f));
+                _("%s has appeared;  following end of new file"),
+                quote (pretty_name (f)));
        }
       else
        {
@@ -934,8 +934,8 @@ recheck (struct File_spec *f, bool blocking)
          /* File has been replaced (e.g., via log rotation) --
             tail the new one.  */
          error (0, 0,
-                _("`%s' has been replaced;  following end of new file"),
-                pretty_name (f));
+                _("%s has been replaced;  following end of new file"),
+                quote (pretty_name (f)));
        }
     }
   else
@@ -1446,7 +1446,7 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units)
   else if ((xstrtoumax (n_string, NULL, 10, n_units, "b")
            & ~LONGINT_INVALID_SUFFIX_CHAR)
           != LONGINT_OK)
-    error (EXIT_FAILURE, 0, _("number in `%s' is too large"), argv[1]);
+    error (EXIT_FAILURE, 0, _("number in %s is too large"), quote (argv[1]));
 
   /* Set globals.  */
   from_start = t_from_start;