m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] m4: translate more strings


From: Eric Blake
Subject: [PATCH 4/4] m4: translate more strings
Date: Mon, 10 May 2021 16:37:42 -0500

* src/m4.c (usage): Split large paragraphs, and mark for translation.
(main): Translate more strings.
* src/builtin.c: Likewise.
* src/eval.c (evaluate): Likewise.
* src/format.c (expand_format): Likewise.
* src/freeze.c: Likewise.
* src/input.c: Likewise.
* src/macro.c: Likewise.
* src/output.c: Likewise.
Reported by Benno Schulenberg:
https://lists.gnu.org/archive/html/m4-discuss/2021-05/msg00005.html
---
 src/builtin.c | 90 +++++++++++++++++++++++++--------------------------
 src/debug.c   |  4 +--
 src/eval.c    | 20 ++++++------
 src/format.c  |  2 +-
 src/freeze.c  | 16 ++++-----
 src/input.c   | 12 +++----
 src/m4.c      | 71 +++++++++++++++++++++++-----------------
 src/macro.c   |  4 +--
 src/output.c  | 20 ++++++------
 9 files changed, 125 insertions(+), 114 deletions(-)

diff --git a/src/builtin.c b/src/builtin.c
index 9aaa4750..5e36ab35 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -261,7 +261,7 @@ set_macro_sequence (const char *regexp)

   msg = re_compile_pattern (regexp, strlen (regexp), &macro_sequence_buf);
   if (msg != NULL)
-    m4_failure (0, "--warn-macro-sequence: bad regular expression `%s': %s",
+    m4_failure (0, _("--warn-macro-sequence: bad regular expression `%s': %s"),
                 regexp, msg);
   re_set_registers (&macro_sequence_buf, &macro_sequence_regs,
                     macro_sequence_regs.num_regs,
@@ -317,14 +317,14 @@ define_user_macro (const char *name, const char *text, 
symbol_lookup mode)
               tmp = defn[offset];
               defn[offset] = '\0';
               M4ERROR ((warning_status, 0,
-                        "Warning: definition of `%s' contains sequence `%s'",
+                        _("Warning: definition of `%s' contains sequence 
`%s'"),
                         name, defn + macro_sequence_regs.start[0]));
               defn[offset] = tmp;
             }
         }
       if (offset == -2)
         M4ERROR ((warning_status, 0,
-                  "error checking --warn-macro-sequence for macro `%s'",
+                  _("error checking --warn-macro-sequence for macro `%s'"),
                   name));
     }
 }
@@ -385,13 +385,13 @@ bad_argc (token_data *name, int argc, int min, int max)
     {
       if (!suppress_warnings)
         M4ERROR ((warning_status, 0,
-                  "Warning: too few arguments to builtin `%s'",
+                  _("Warning: too few arguments to builtin `%s'"),
                   TOKEN_DATA_TEXT (name)));
       isbad = true;
     }
   else if (max > 0 && argc > max && !suppress_warnings)
     M4ERROR ((warning_status, 0,
-              "Warning: excess arguments to builtin `%s' ignored",
+              _("Warning: excess arguments to builtin `%s' ignored"),
               TOKEN_DATA_TEXT (name)));

   return isbad;
@@ -412,7 +412,7 @@ numeric_arg (token_data *macro, const char *arg, int 
*valuep)
     {
       *valuep = 0;
       M4ERROR ((warning_status, 0,
-                "empty string treated as 0 in builtin `%s'",
+                _("empty string treated as 0 in builtin `%s'"),
                 TOKEN_DATA_TEXT (macro)));
     }
   else
@@ -422,17 +422,17 @@ numeric_arg (token_data *macro, const char *arg, int 
*valuep)
       if (*endp != '\0')
         {
           M4ERROR ((warning_status, 0,
-                    "non-numeric argument to builtin `%s'",
+                    _("non-numeric argument to builtin `%s'"),
                     TOKEN_DATA_TEXT (macro)));
           return false;
         }
       if (c_isspace (*arg))
         M4ERROR ((warning_status, 0,
-                  "leading whitespace ignored in builtin `%s'",
+                  _("leading whitespace ignored in builtin `%s'"),
                   TOKEN_DATA_TEXT (macro)));
       else if (errno == ERANGE)
         M4ERROR ((warning_status, 0,
-                  "numeric overflow detected in builtin `%s'",
+                  _("numeric overflow detected in builtin `%s'"),
                   TOKEN_DATA_TEXT (macro)));
     }
   return true;
@@ -549,7 +549,7 @@ define_macro (int argc, token_data **argv, symbol_lookup 
mode)
   if (TOKEN_DATA_TYPE (argv[1]) != TOKEN_TEXT)
     {
       M4ERROR ((warning_status, 0,
-                "Warning: %s: invalid macro name ignored", ARG (0)));
+                _("Warning: %s: invalid macro name ignored"), ARG (0)));
       return;
     }

@@ -749,7 +749,7 @@ m4_dumpdef (struct obstack *obs, int argc, token_data 
**argv)
             dump_symbol (s, &data);
           else
             M4ERROR ((warning_status, 0,
-                      "undefined macro `%s'", TOKEN_DATA_TEXT (argv[i])));
+                      _("undefined macro `%s'"), TOKEN_DATA_TEXT (argv[i])));
         }
     }

@@ -812,7 +812,7 @@ m4_builtin (struct obstack *obs, int argc, token_data 
**argv)
   if (TOKEN_DATA_TYPE (argv[1]) != TOKEN_TEXT)
     {
       M4ERROR ((warning_status, 0,
-                "Warning: %s: invalid macro name ignored", ARG (0)));
+                _("Warning: %s: invalid macro name ignored"), ARG (0)));
       return;
     }

@@ -820,7 +820,7 @@ m4_builtin (struct obstack *obs, int argc, token_data 
**argv)
   bp = find_builtin_by_name (name);
   if (bp->func == m4_placeholder)
     M4ERROR ((warning_status, 0,
-              "undefined builtin `%s'", name));
+              _("undefined builtin `%s'"), name));
   else
     {
       int i;
@@ -853,7 +853,7 @@ m4_indir (struct obstack *obs, int argc, token_data **argv)
   if (TOKEN_DATA_TYPE (argv[1]) != TOKEN_TEXT)
     {
       M4ERROR ((warning_status, 0,
-                "Warning: %s: invalid macro name ignored", ARG (0)));
+                _("Warning: %s: invalid macro name ignored"), ARG (0)));
       return;
     }

@@ -861,7 +861,7 @@ m4_indir (struct obstack *obs, int argc, token_data **argv)
   s = lookup_symbol (name, SYMBOL_LOOKUP);
   if (s == NULL || SYMBOL_TYPE (s) == TOKEN_VOID)
     M4ERROR ((warning_status, 0,
-              "undefined macro `%s'", name));
+              _("undefined macro `%s'"), name));
   else
     {
       int i;
@@ -911,11 +911,11 @@ m4_defn (struct obstack *obs, int argc, token_data **argv)
         case TOKEN_FUNC:
           b = SYMBOL_FUNC (s);
           if (b == m4_placeholder)
-            M4ERROR ((warning_status, 0, "\
-builtin `%s' requested by frozen file is not supported", arg));
+            M4ERROR ((warning_status, 0, _("\
+builtin `%s' requested by frozen file is not supported"), arg));
           else if (argc != 2)
             M4ERROR ((warning_status, 0,
-                      "Warning: cannot concatenate builtin `%s'",
+                      _("Warning: cannot concatenate builtin `%s'"),
                       arg));
           else
             push_macro (b);
@@ -975,7 +975,7 @@ m4_syscmd (struct obstack *obs MAYBE_UNUSED, int argc, 
token_data **argv)
   else
     {
       if (status == 127 && errno)
-        M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+        M4ERROR ((warning_status, errno, _("cannot run command `%s'"), cmd));
       sysval = status;
     }
 }
@@ -1012,7 +1012,7 @@ m4_esyscmd (struct obstack *obs, int argc, token_data 
**argv)
                           NULL, false, true, false, &fd);
   if (child == -1)
     {
-      M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+      M4ERROR ((warning_status, errno, _("cannot run command `%s'"), cmd));
       sysval = 127;
       return;
     }
@@ -1025,7 +1025,7 @@ m4_esyscmd (struct obstack *obs, int argc, token_data 
**argv)
 #endif
   if (pin == NULL)
     {
-      M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+      M4ERROR ((warning_status, errno, _("cannot run command `%s'"), cmd));
       sysval = 127;
       close (fd);
       return;
@@ -1048,7 +1048,7 @@ m4_esyscmd (struct obstack *obs, int argc, token_data 
**argv)
       obstack_blank_fast (obs, len);
     }
   if (ferror (pin) || fclose (pin))
-    m4_failure (errno, "cannot read pipe");
+    m4_failure (errno, _("cannot read pipe"));
   errno = 0;
   status = wait_subprocess (child, ARG (0), false, true, true, false,
                             &sig_status);
@@ -1060,7 +1060,7 @@ m4_esyscmd (struct obstack *obs, int argc, token_data 
**argv)
   else
     {
       if (status == 127 && errno)
-        M4ERROR ((warning_status, errno, "cannot run command `%s'", cmd));
+        M4ERROR ((warning_status, errno, _("cannot run command `%s'"), cmd));
       sysval = status;
     }
 }
@@ -1095,7 +1095,7 @@ m4_eval (struct obstack *obs, int argc, token_data **argv)
   if (radix < 1 || radix > (int) strlen (digits))
     {
       M4ERROR ((warning_status, 0,
-                "radix %d in builtin `%s' out of range",
+                _("radix %d in builtin `%s' out of range"),
                 radix, ARG (0)));
       return;
     }
@@ -1105,13 +1105,13 @@ m4_eval (struct obstack *obs, int argc, token_data 
**argv)
   if (min < 0)
     {
       M4ERROR ((warning_status, 0,
-                "negative width to builtin `%s'", ARG (0)));
+                _("negative width to builtin `%s'"), ARG (0)));
       return;
     }

   if (!*ARG (1))
     M4ERROR ((warning_status, 0,
-              "empty string treated as 0 in builtin `%s'", ARG (0)));
+              _("empty string treated as 0 in builtin `%s'"), ARG (0)));
   else if (evaluate (ARG (1), &value))
     return;

@@ -1240,7 +1240,7 @@ m4_undivert (struct obstack *obs MAYBE_UNUSED, int argc, 
token_data **argv)
           insert_diversion (file);
         else if (no_gnu_extensions)
           M4ERROR ((warning_status, 0,
-                    "non-numeric argument to builtin `%s'", ARG (0)));
+                    _("non-numeric argument to builtin `%s'"), ARG (0)));
         else
           {
             fp = m4_path_search (ARG (i), NULL);
@@ -1249,11 +1249,11 @@ m4_undivert (struct obstack *obs MAYBE_UNUSED, int 
argc, token_data **argv)
                 insert_file (fp);
                 if (fclose (fp) == EOF)
                   M4ERROR ((warning_status, errno,
-                            "error undiverting `%s'", ARG (i)));
+                            _("error undiverting `%s'"), ARG (i)));
               }
             else
               M4ERROR ((warning_status, errno,
-                        "cannot undivert `%s'", ARG (i)));
+                        _("cannot undivert `%s'"), ARG (i)));
           }
       }
 }
@@ -1363,7 +1363,7 @@ include (int argc, token_data **argv, bool silent)
     {
       if (!silent)
         {
-          M4ERROR ((warning_status, errno, "cannot open `%s'", ARG (1)));
+          M4ERROR ((warning_status, errno, _("cannot open `%s'"), ARG (1)));
           retcode = EXIT_FAILURE;
         }
       return;
@@ -1426,7 +1426,7 @@ mkstemp_helper (struct obstack *obs, const char *me, 
const char *pattern,
   fd = mkstemp (name);
   if (fd < 0)
     {
-      M4ERROR ((0, errno, "%s: cannot create tempfile `%s'", me, pattern));
+      M4ERROR ((0, errno, _("%s: cannot create tempfile `%s'"), me, pattern));
       obstack_free (obs, obstack_finish (obs));
     }
   else
@@ -1461,7 +1461,7 @@ m4_maketemp (struct obstack *obs, int argc, token_data 
**argv)
       int i;
       int len2;

-      M4ERROR ((warning_status, 0, "recommend using mkstemp instead"));
+      M4ERROR ((warning_status, 0, _("recommend using mkstemp instead")));
       for (i = len; i > 1; i--)
         if (str[i - 1] != 'X')
           break;
@@ -1554,7 +1554,7 @@ m4_m4exit (struct obstack *obs MAYBE_UNUSED, int argc, 
token_data **argv)
   if (exit_code < 0 || exit_code > 255)
     {
       M4ERROR ((warning_status, 0,
-                "exit status out of range: `%d'", exit_code));
+                _("exit status out of range: `%d'"), exit_code));
       exit_code = EXIT_FAILURE;
     }
   /* Change debug stream back to stderr, to force flushing debug stream and
@@ -1678,7 +1678,7 @@ m4_debugmode (struct obstack *obs MAYBE_UNUSED, int argc, 
token_data **argv)

       if (new_debug_level < 0)
         M4ERROR ((warning_status, 0,
-                  "Debugmode: bad debug flags: `%s'", ARG (1)));
+                  _("Debugmode: bad debug flags: `%s'"), ARG (1)));
       else
         {
           switch (change_flag)
@@ -1719,7 +1719,7 @@ m4_debugfile (struct obstack *obs MAYBE_UNUSED, int argc, 
token_data **argv)
     debug_set_output (NULL);
   else if (!debug_set_output (ARG (1)))
     M4ERROR ((warning_status, errno,
-              "cannot set debug file `%s'", ARG (1)));
+              _("cannot set debug file `%s'"), ARG (1)));
 }
 
 /* This section contains text processing macros: "len", "index",
@@ -1985,8 +1985,8 @@ substitute (struct obstack *obs, const char *victim, 
const char *repl,
         case '0':
           if (!substitute_warned)
             {
-              M4ERROR ((warning_status, 0, "\
-Warning: \\0 will disappear, use \\& instead in replacements"));
+              M4ERROR ((warning_status, 0, _("\
+Warning: \\0 will disappear, use \\& instead in replacements")));
               substitute_warned = 1;
             }
           FALLTHROUGH;
@@ -2001,7 +2001,7 @@ Warning: \\0 will disappear, use \\& instead in 
replacements"));
           ind = ch -= '0';
           if (regs->num_regs - 1 <= ind)
             M4ERROR ((warning_status, 0,
-                      "Warning: sub-expression %d not present", ch));
+                      _("Warning: sub-expression %d not present"), ch));
           else if (regs->end[ch] > 0)
             obstack_grow (obs, victim + regs->start[ch],
                           regs->end[ch] - regs->start[ch]);
@@ -2010,7 +2010,7 @@ Warning: \\0 will disappear, use \\& instead in 
replacements"));

         case '\0':
           M4ERROR ((warning_status, 0,
-                    "Warning: trailing \\ ignored in replacement"));
+                    _("Warning: trailing \\ ignored in replacement")));
           return;

         default:
@@ -2076,7 +2076,7 @@ m4_regexp (struct obstack *obs, int argc, token_data 
**argv)
   if (msg != NULL)
     {
       M4ERROR ((warning_status, 0,
-                "bad regular expression: `%s': %s", regexp, msg));
+                _("bad regular expression: `%s': %s"), regexp, msg));
       free_pattern_buffer (&buf, &regs);
       return;
     }
@@ -2088,7 +2088,7 @@ m4_regexp (struct obstack *obs, int argc, token_data 
**argv)

   if (startpos == -2)
     M4ERROR ((warning_status, 0,
-               "error matching regular expression `%s'", regexp));
+              _("error matching regular expression `%s'"), regexp));
   else if (argc == 3)
     shipout_int (obs, startpos);
   else if (startpos >= 0)
@@ -2136,7 +2136,7 @@ m4_patsubst (struct obstack *obs, int argc, token_data 
**argv)
   if (msg != NULL)
     {
       M4ERROR ((warning_status, 0,
-                "bad regular expression `%s': %s", regexp, msg));
+                _("bad regular expression `%s': %s"), regexp, msg));
       free (buf.buffer);
       return;
     }
@@ -2158,7 +2158,7 @@ m4_patsubst (struct obstack *obs, int argc, token_data 
**argv)

           if (matchpos == -2)
             M4ERROR ((warning_status, 0,
-                      "error matching regular expression `%s'", regexp));
+                      _("error matching regular expression `%s'"), regexp));
           else if (offset < length)
             obstack_grow (obs, victim + offset, length - offset);
           break;
@@ -2205,8 +2205,8 @@ void
 m4_placeholder (struct obstack *obs MAYBE_UNUSED, int argc,
                 token_data **argv)
 {
-  M4ERROR ((warning_status, 0, "\
-builtin `%s' requested by frozen file is not supported", ARG (0)));
+  M4ERROR ((warning_status, 0, _("\
+builtin `%s' requested by frozen file is not supported"), ARG (0)));
 }
 
 /*-------------------------------------------------------------------.
diff --git a/src/debug.c b/src/debug.c
index daa0f618..47e589d2 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -133,7 +133,7 @@ debug_set_file (FILE *fp)
   if (debug != NULL && debug != stderr && debug != stdout
       && close_stream (debug) != 0)
     {
-      M4ERROR ((warning_status, errno, "error writing to debug stream"));
+      M4ERROR ((warning_status, errno, _("error writing to debug stream")));
       retcode = EXIT_FAILURE;
     }
   debug = fp;
@@ -154,7 +154,7 @@ debug_set_file (FILE *fp)
           if (debug != stderr && close_stream (debug) != 0)
             {
               M4ERROR ((warning_status, errno,
-                        "error writing to debug stream"));
+                        _("error writing to debug stream")));
               retcode = EXIT_FAILURE;
             }
           debug = stdout;
diff --git a/src/eval.c b/src/eval.c
index 4717c3cf..18e3a340 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -315,44 +315,44 @@ evaluate (const char *expr, int32_t *val)

     case MISSING_RIGHT:
       M4ERROR ((warning_status, 0,
-                "bad expression in eval (missing right parenthesis): %s",
+                _("bad expression in eval (missing right parenthesis): %s"),
                 expr));
       break;

     case SYNTAX_ERROR:
       M4ERROR ((warning_status, 0,
-                "bad expression in eval: %s", expr));
+                _("bad expression in eval: %s"), expr));
       break;

     case UNKNOWN_INPUT:
       M4ERROR ((warning_status, 0,
-                "bad expression in eval (bad input): %s", expr));
+                _("bad expression in eval (bad input): %s"), expr));
       break;

     case EXCESS_INPUT:
       M4ERROR ((warning_status, 0,
-                "bad expression in eval (excess input): %s", expr));
+                _("bad expression in eval (excess input): %s"), expr));
       break;

     case INVALID_OPERATOR:
       M4ERROR ((warning_status, 0,
-                "invalid operator in eval: %s", expr));
+                _("invalid operator in eval: %s"), expr));
       retcode = EXIT_FAILURE;
       break;

     case DIVIDE_ZERO:
       M4ERROR ((warning_status, 0,
-                "divide by zero in eval: %s", expr));
+                _("divide by zero in eval: %s"), expr));
       break;

     case MODULO_ZERO:
       M4ERROR ((warning_status, 0,
-                "modulo by zero in eval: %s", expr));
+                _("modulo by zero in eval: %s"), expr));
       break;

     case NEGATIVE_EXPONENT:
       M4ERROR ((warning_status, 0,
-                "negative exponent in eval: %s", expr));
+                _("negative exponent in eval: %s"), expr));
       break;

     default:
@@ -535,8 +535,8 @@ equality_term (eval_token et, int32_t *v1)

       if (op == ASSIGN)
       {
-        M4ERROR ((warning_status, 0, "\
-Warning: recommend ==, not =, for equality operator"));
+        M4ERROR ((warning_status, 0, _("\
+Warning: recommend ==, not =, for equality operator")));
         op = EQ;
       }
       *v1 = (op == EQ) == (*v1 == v2);
diff --git a/src/format.c b/src/format.c
index 7f449656..6f1758f2 100644
--- a/src/format.c
+++ b/src/format.c
@@ -305,7 +305,7 @@ expand_format (struct obstack *obs, int argc, token_data 
**argv)
       if (sizeof ok <= c || !ok[c])
         {
           M4ERROR ((warning_status, 0,
-                    "Warning: unrecognized specifier in `%s'", f));
+                    _("Warning: unrecognized specifier in `%s'"), f));
           if (c == '\0')
             fmt--;
           continue;
diff --git a/src/freeze.c b/src/freeze.c
index c706f40d..94671c32 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -112,7 +112,7 @@ produce_frozen_state (const char *name)

   file = fopen (name, O_BINARY ? "wbe" : "we");
   if (!file)
-    m4_failure (errno, "cannot open `%s'", name);
+    m4_failure (errno, _("cannot open `%s'"), name);

   /* Write a recognizable header.  */

@@ -153,7 +153,7 @@ produce_frozen_state (const char *name)

   fputs ("# End of frozen state file\n", file);
   if (close_stream (file) != 0)
-    m4_failure (errno, "unable to create frozen state");
+    m4_failure (errno, _("unable to create frozen state"));
 }

 /*----------------------------------------------------------------------.
@@ -164,9 +164,9 @@ static void
 issue_expect_message (int expected)
 {
   if (expected == '\n')
-    m4_failure (0, "expecting line feed in frozen file");
+    m4_failure (0, _("expecting line feed in frozen file"));
   else
-    m4_failure (0, "expecting character `%c' in frozen file", expected);
+    m4_failure (0, _("expecting character `%c' in frozen file"), expected);
 }

 /*-------------------------------------------------.
@@ -267,7 +267,7 @@ reload_frozen_state (const char *name)

   file = m4_path_search (name, NULL);
   if (file == NULL)
-    m4_failure (errno, "cannot open %s", name);
+    m4_failure (errno, _("cannot open %s"), name);
   current_file = name;

   allocated[0] = 100;
@@ -282,10 +282,10 @@ reload_frozen_state (const char *name)
   GET_NUMBER (number[0], false);
   if (number[0] > 1)
     M4ERROR ((EXIT_MISMATCH, 0,
-              "frozen file version %d greater than max supported of 1",
+              _("frozen file version %d greater than max supported of 1"),
               number[0]));
   else if (number[0] < 1)
-    m4_failure (0, "ill-formed frozen file, version directive expected");
+    m4_failure (0, _("ill-formed frozen file, version directive expected"));
   VALIDATE ('\n');

   GET_DIRECTIVE;
@@ -294,7 +294,7 @@ reload_frozen_state (const char *name)
       switch (character)
         {
         default:
-          m4_failure (0, "ill-formed frozen file");
+          m4_failure (0, _("ill-formed frozen file"));

         case 'C':
         case 'D':
diff --git a/src/input.c b/src/input.c
index 840fc9a1..727ac7f9 100644
--- a/src/input.c
+++ b/src/input.c
@@ -356,14 +356,14 @@ pop_input (void)

       if (ferror (isp->u.u_f.fp))
         {
-          M4ERROR ((warning_status, 0, "read error"));
+          M4ERROR ((warning_status, 0, _("read error")));
           if (isp->u.u_f.close)
             fclose (isp->u.u_f.fp);
           retcode = EXIT_FAILURE;
         }
       else if (isp->u.u_f.close && fclose (isp->u.u_f.fp) == EOF)
         {
-          M4ERROR ((warning_status, errno, "error reading file"));
+          M4ERROR ((warning_status, errno, _("error reading file")));
           retcode = EXIT_FAILURE;
         }
       start_of_input_line = isp->u.u_f.advance;
@@ -586,7 +586,7 @@ skip_line (void)
     /* current_file changed to "" if we see CHAR_EOF, use the
        previous value we stored earlier.  */
     M4ERROR_AT_LINE ((warning_status, 0, file, line,
-                      "Warning: end of file treated as newline"));
+                      _("Warning: end of file treated as newline")));
   /* On the rare occasion that dnl crosses include file boundaries
      (either the input file did not end in a newline, or changeword
      was used), calling next_char can update current_file and
@@ -789,7 +789,7 @@ set_word_regexp (const char *regexp)
   if (msg != NULL)
     {
       M4ERROR ((warning_status, 0,
-                "bad regular expression `%s': %s", regexp, msg));
+                _("bad regular expression `%s': %s"), regexp, msg));
       return;
     }

@@ -878,7 +878,7 @@ next_token (token_data *td, int *line)
       else
         /* current_file changed to "" if we see CHAR_EOF, use the
            previous value we stored earlier.  */
-        m4_failure_at_line (0, file, *line, "ERROR: end of file in comment");
+        m4_failure_at_line (0, file, *line, _("ERROR: end of file in 
comment"));

       type = TOKEN_STRING;
     }
@@ -998,7 +998,7 @@ next_token (token_data *td, int *line)
             /* current_file changed to "" if we see CHAR_EOF, use
                the previous value we stored earlier.  */
             m4_failure_at_line (0, file, *line,
-                                "ERROR: end of file in string");
+                                _("ERROR: end of file in string"));

           if (MATCH (ch, rquote.string, true))
             {
diff --git a/src/m4.c b/src/m4.c
index 49197708..592e4883 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -203,46 +203,54 @@ static void
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
-    xfprintf (stderr, "Try `%s --help' for more information.\n", program_name);
+    {
+      xfprintf (stderr, _("Try `%s --help' for more information."),
+                program_name);
+      fputs ("\n", stderr);
+    }
   else
     {
-      xprintf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
-      fputs ("\
+      xprintf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
+      fputs (_("\
 Process macros in FILEs.  If no FILE or if FILE is `-', standard input\n\
 is read.\n\
-", stdout);
-      fputs ("\
-\n\
+"), stdout);
+      puts ("");
+      fputs (_("\
 Mandatory or optional arguments to long options are mandatory or optional\n\
 for short options too.\n\
-\n\
+"), stdout);
+      puts ("");
+      fputs (_("\
 Operation modes:\n\
       --help                   display this help and exit\n\
       --version                output version information and exit\n\
-", stdout);
-      xprintf ("\
+"), stdout);
+      fputs (_("\
   -E, --fatal-warnings         once: warnings become errors, twice: stop\n\
                                  execution at first error\n\
   -i, --interactive            unbuffer output, ignore interrupts\n\
   -P, --prefix-builtins        force a `m4_' prefix to all builtins\n\
   -Q, --quiet, --silent        suppress some warnings for builtins\n\
+"), stdout);
+      xprintf (_("\
       --warn-macro-sequence[=REGEXP]\n\
                                warn if macro definition matches REGEXP,\n\
                                  default %s\n\
-", DEFAULT_MACRO_SEQUENCE);
+"), DEFAULT_MACRO_SEQUENCE);
 #ifdef ENABLE_CHANGEWORD
-      fputs ("\
+      fputs (_("\
   -W, --word-regexp=REGEXP     use REGEXP for macro name syntax\n\
-", stdout);
+"), stdout);
 #endif
-      fputs ("\
+      fputs (_("\
 \n\
 Preprocessor features:\n\
   -D, --define=NAME[=VALUE]    define NAME as having VALUE, or empty\n\
   -I, --include=DIRECTORY      append DIRECTORY to include path\n\
   -s, --synclines              generate `#line NUM \"FILE\"' lines\n\
   -U, --undefine=NAME          undefine NAME\n\
-", stdout);
+"), stdout);
       puts ("");
       xprintf (_("\
 Limits control:\n\
@@ -252,45 +260,47 @@ Limits control:\n\
   -L, --nesting-limit=NUMBER   change nesting limit, 0 for unlimited [%d]\n\
 "), nesting_limit);
       puts ("");
-      fputs ("\
+      fputs (_("\
 Frozen state files:\n\
   -F, --freeze-state=FILE      produce a frozen state on FILE at end\n\
   -R, --reload-state=FILE      reload a frozen state from FILE at start\n\
-", stdout);
-      fputs ("\
-\n\
+"), stdout);
+      puts ("");
+      fputs (_("\
 Debugging:\n\
   -d, --debug[=FLAGS]          set debug level (no FLAGS implies `aeq')\n\
       --debugfile[=FILE]       redirect debug and trace output to FILE\n\
                                  (default stderr, discard if empty string)\n\
   -l, --arglength=NUM          restrict macro tracing size\n\
   -t, --trace=NAME             trace NAME when it is defined\n\
-", stdout);
-      fputs ("\
-\n\
+"), stdout);
+      puts ("");
+      fputs (_("\
 FLAGS is any of:\n\
   a   show actual arguments\n\
   c   show before collect, after collect and after call\n\
   e   show expansion\n\
   f   say current input file name\n\
   i   show changes in input files\n\
+"), stdout);
+      fputs (_("\
   l   say current input line number\n\
   p   show results of path searches\n\
   q   quote values as necessary, with a or e flag\n\
   t   trace for all macro calls, not only traceon'ed\n\
   x   add a unique macro call id, useful with c flag\n\
   V   shorthand for all of the above flags\n\
-", stdout);
-      fputs ("\
-\n\
+"), stdout);
+      puts ("");
+      fputs (_("\
 If defined, the environment variable `M4PATH' is a colon-separated list\n\
 of directories included after any specified by `-I'.\n\
-", stdout);
-      fputs ("\
-\n\
+"), stdout);
+      puts ("");
+      fputs (_("\
 Exit status is 0 for success, 1 for failure, 63 for frozen file version\n\
 mismatch, or whatever value was passed to the m4exit macro.\n\
-", stdout);
+"), stdout);
       emit_bug_reporting_address ();
     }
   exit (status);
@@ -612,7 +622,8 @@ main (int argc, char *const *argv)

   /* Do the basic initializations.  */
   if (debugfile && !debug_set_output (debugfile))
-    M4ERROR ((warning_status, errno, "cannot set debug file `%s'", debugfile));
+    M4ERROR ((warning_status, errno, _("cannot set debug file `%s'"),
+              debugfile));

   input_init ();
   output_init ();
@@ -675,7 +686,7 @@ main (int argc, char *const *argv)

         case DEBUGFILE_OPTION:
           if (!debug_set_output (defines->arg))
-            M4ERROR ((warning_status, errno, "cannot set debug file `%s'",
+            M4ERROR ((warning_status, errno, _("cannot set debug file `%s'"),
                       debugfile ? debugfile : _("stderr")));
           break;

diff --git a/src/macro.c b/src/macro.c
index 29e81b0f..7359e43c 100644
--- a/src/macro.c
+++ b/src/macro.c
@@ -193,7 +193,7 @@ expand_argument (struct obstack *obs, token_data *argp)
           /* current_file changed to "" if we see TOKEN_EOF, use the
              previous value we stored earlier.  */
           m4_failure_at_line (0, file, line,
-                              "ERROR: end of file in argument list");
+                              _("ERROR: end of file in argument list"));

         case TOKEN_WORD:
         case TOKEN_STRING:
@@ -329,7 +329,7 @@ expand_macro (symbol *sym)
   SYMBOL_PENDING_EXPANSIONS (sym)++;
   expansion_level++;
   if (nesting_limit > 0 && expansion_level > nesting_limit)
-    m4_failure (0, "recursion limit of %d exceeded, use -L<N> to change it",
+    m4_failure (0, _("recursion limit of %d exceeded, use -L<N> to change it"),
                 nesting_limit);

   macro_call_id++;
diff --git a/src/output.c b/src/output.c
index e4a447a1..6f148ceb 100644
--- a/src/output.c
+++ b/src/output.c
@@ -169,7 +169,7 @@ cleanup_tmpfile (void)
               && close_stream_temp (diversion->u.file) != 0)
             {
               M4ERROR ((0, errno,
-                        "cannot clean temporary file for diversion"));
+                        _("cannot clean temporary file for diversion")));
               fail = true;
             }
         }
@@ -219,7 +219,7 @@ m4_tmpfile (int divnum)
     {
       output_temp_dir = create_temp_dir ("m4-", NULL, true);
       if (output_temp_dir == NULL)
-        m4_failure (errno, "cannot create temporary file for diversion");
+        m4_failure (errno, _("cannot create temporary file for diversion"));
       atexit (cleanup_tmpfile);
     }
   name = m4_tmpname (divnum);
@@ -228,7 +228,7 @@ m4_tmpfile (int divnum)
   if (file == NULL)
     {
       unregister_temp_file (output_temp_dir, name);
-      m4_failure (errno, "cannot create temporary file for diversion");
+      m4_failure (errno, _("cannot create temporary file for diversion"));
     }
   return file;
 }
@@ -262,7 +262,7 @@ m4_tmpopen (int divnum, bool reread)
   /* We need update mode, to avoid truncation.  */
   file = fopen_temp (name, O_BINARY ? "rb+e" : "r+e", false);
   if (file == NULL)
-    m4_failure (errno, "cannot create temporary file for diversion");
+    m4_failure (errno, _("cannot create temporary file for diversion"));
   /* Update mode starts at the beginning of the stream, but sometimes
      we want the end.  */
   else if (!reread && fseeko (file, 0, SEEK_END) != 0)
@@ -471,7 +471,7 @@ make_room_for (int length)
                           1, selected_diversion->u.file);
           if (count != 1)
             m4_failure (errno,
-                        "ERROR: cannot flush diversion to temporary file");
+                        _("ERROR: cannot flush diversion to temporary file"));
         }

       /* Reclaim the buffer space for other diversions.  */
@@ -565,7 +565,7 @@ output_text (const char *text, int length)
     {
       count = fwrite (text, length, 1, output_file);
       if (count != 1)
-        m4_failure (errno, "ERROR: copying inserted file");
+        m4_failure (errno, _("ERROR: copying inserted file"));
     }
   else
     {
@@ -813,7 +813,7 @@ insert_file (FILE *file)
     {
       length = fread (buffer, 1, sizeof buffer, file);
       if (ferror (file))
-        m4_failure (errno, "error reading inserted file");
+        m4_failure (errno, _("error reading inserted file"));
       if (length == 0)
         break;
       output_text (buffer, length);
@@ -898,7 +898,7 @@ insert_diversion_helper (m4_diversion *diversion)
                       _("cannot clean temporary file for diversion"));
         }
       if (m4_tmpremove (diversion->divnum) != 0)
-        M4ERROR ((0, errno, "cannot clean temporary file for diversion"));
+        M4ERROR ((0, errno, _("cannot clean temporary file for diversion")));
     }
   diversion->used = 0;
   gl_oset_remove (diversion_table, diversion);
@@ -980,11 +980,11 @@ freeze_diversions (FILE *file)
               struct stat file_stat;
               diversion->u.file = m4_tmpopen (diversion->divnum, true);
               if (fstat (fileno (diversion->u.file), &file_stat) < 0)
-                m4_failure (errno, "cannot stat diversion");
+                m4_failure (errno, _("cannot stat diversion"));
               if (file_stat.st_size < 0
                   || (file_stat.st_size + 0UL
                       != (unsigned long int) file_stat.st_size))
-                m4_failure (0, "diversion too large");
+                m4_failure (0, _("diversion too large"));
               xfprintf (file, "D%d,%lu\n", diversion->divnum,
                         (unsigned long int) file_stat.st_size);
             }
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]