]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Prefix most error messages with the program name.
authorBruno Haible <bruno@clisp.org>
Mon, 7 May 2001 13:16:33 +0000 (13:16 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 7 May 2001 13:16:33 +0000 (13:16 +0000)
13 files changed:
lib/ChangeLog
lib/progname.c [new file with mode: 0644]
lib/progname.h [new file with mode: 0644]
src/ChangeLog
src/msgcmp.c
src/msgcomm.c
src/msgfmt.c
src/msgmerge.c
src/msgunfmt.c
src/po-lex.c
src/po-lex.h
src/xget-lex.c
src/xgettext.c

index 265db3969f68fda77e5e01f874af21e914378e29..2a1736afe15ee4a4f9f6d025f857786320fea540 100644 (file)
@@ -1,3 +1,12 @@
+2001-05-01  Bruno Haible  <haible@clisp.cons.org>
+
+       Prefix most error messages with the program name, except those
+       starting with "filename:lineno:".
+       * progname.h: New file.
+       * progname.c: New file.
+       * Makefile.am (libnlsut_a_SOURCES): Add progname.c.
+       (noinst_HEADERS): Add progname.h.
+
 2001-05-01  Bruno Haible  <haible@clisp.cons.org>
 
        * vasprintf.c (int_vasprintf): Upon allocation failure, return -1,
diff --git a/lib/progname.c b/lib/progname.c
new file mode 100644 (file)
index 0000000..7068b39
--- /dev/null
@@ -0,0 +1,44 @@
+/* Program name management.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "progname.h"
+
+
+/* String containing name the program is called with.
+   To be initialized by main().  */
+const char *program_name;
+
+/* Indicates whether errors and warnings get prefixed with program_name.
+   Default is true.  */
+int error_with_progname = 1;
+
+/* Print program_name prefix on stderr if and only if error_with_progname
+   is true.  */
+void
+maybe_print_progname ()
+{
+  if (error_with_progname)
+    fprintf (stderr, "%s: ", program_name);
+}
diff --git a/lib/progname.h b/lib/progname.h
new file mode 100644 (file)
index 0000000..7ddd306
--- /dev/null
@@ -0,0 +1,43 @@
+/* Program name management.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _PROGNAME_H
+#define _PROGNAME_H
+
+/* This file supports selectively prefixing or nor prefixing error messages
+   with the program name.
+
+   Programs using this file should do the following in main():
+     program_name = argv[0];
+     error_print_progname = maybe_print_progname;
+ */
+
+/* String containing name the program is called with.  */
+extern const char *program_name;
+
+/* Indicates whether errors and warnings get prefixed with program_name.
+   Default is true.
+   A reason to omit the prefix is for better interoperability with Emacs'
+   compile.el.  */
+extern int error_with_progname;
+
+/* Print program_name prefix on stderr if and only if error_with_progname
+   is true.  */
+extern void maybe_print_progname PARAMS ((void));
+
+#endif /* _PROGNAME_H */
index 44c5801f527707a079c89b7c66c1359e0635b9a2..d84d63d09bd4ea54836e31c2a2bd4ef5e613c864 100644 (file)
@@ -1,3 +1,44 @@
+2001-05-01  Bruno Haible  <haible@clisp.cons.org>
+
+       Prefix most error messages with the program name, except those
+       starting with "filename:lineno:".
+       * po-lex.h: Include progname.h.
+       (po_gram_error): Set error_with_progname = 0 during error_at_line()
+       call.
+       (po_gram_error_at_line): Likewise.
+       * po-lex.c (po_gram_error): Likewise.
+       (po_gram_error_at_line): Likewise.
+       * msgcmp.c: Include progname.h.
+       (program_name): Remove variable.
+       (error_print): Remove function.
+       (main): Initialize error_print_progname with maybe_print_progname.
+       * msgcomm.c: Include progname.h.
+       (program_name): Remove variable.
+       (error_print): Remove function.
+       (main): Initialize error_print_progname with maybe_print_progname.
+       * msgfmt.c: Include progname.h.
+       (program_name): Remove variable.
+       (error_print): Remove function.
+       (main): Initialize error_print_progname with maybe_print_progname.
+       (format_directive_message): Set error_with_progname = 0 during
+       error_at_line() call.
+       (check_pair): Likewise.
+       * msgmerge.c: Include progname.h.
+       (program_name): Remove variable.
+       (error_print): Remove function.
+       (main): Initialize error_print_progname with maybe_print_progname.
+       * msgunfmt.c: Include progname.h.
+       (program_name): Remove variable.
+       (error_print): Remove function.
+       (main): Initialize error_print_progname with maybe_print_progname.
+       * xget-lex.c: Include progname.h.
+       (phase5_get): Set error_with_progname = 0 during error() call.
+       * xgettext.c: Include progname.h.
+       (program_name): Remove variable.
+       (error_print): Remove function.
+       (main): Initialize error_print_progname with maybe_print_progname.
+       (scan_c_file): Set error_with_progname = 0 during error() call.
+
 2001-04-30  Bruno Haible  <haible@clisp.cons.org>
 
        Save the messages' obsoleteness status in the 'message_ty'.
index 816cbe1c75eeff451ae59c89b2e9ca8bbfe71e95..e17af95ad135dee5326f40117e011a4ff04baa30 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "dir-list.h"
 #include "error.h"
+#include "progname.h"
 #include "message.h"
 #include <system.h>
 #include "libgettext.h"
@@ -54,9 +55,6 @@ struct compare_class_ty
   message_list_ty *mlp;
 };
 
-/* String containing name the program is called with.  */
-const char *program_name;
-
 /* Long options.  */
 static const struct option long_options[] =
 {
@@ -69,7 +67,6 @@ static const struct option long_options[] =
 
 /* Prototypes for local functions.  */
 static void usage PARAMS ((int __status));
-static void error_print PARAMS ((void));
 static void compare PARAMS ((char *, char *));
 static message_list_ty *grammar PARAMS ((char *__filename));
 static void compare_constructor PARAMS ((po_ty *__that));
@@ -96,7 +93,7 @@ main (argc, argv)
 
   /* Set program name for messages.  */
   program_name = argv[0];
-  error_print_progname = error_print;
+  error_print_progname = maybe_print_progname;
 
 #ifdef HAVE_SETLOCALE
   /* Set locale via LC_ALL.  */
@@ -216,16 +213,6 @@ Informative output:\n\
 }
 
 
-/* The address of this function will be assigned to the hook in the error
-   functions.  */
-static void
-error_print ()
-{
-  /* We don't want the program name to be printed in messages.  Emacs'
-     compile.el does not like this.  */
-}
-
-
 static void
 compare (fn1, fn2)
      char *fn1;
index 7e4917a9c751dbf91dc341062955fe250aa45075..dbfcb80f8615b88236926657a35c0eaa6ad7bbe8 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "dir-list.h"
 #include "error.h"
+#include "progname.h"
 #include "getline.h"
 #include "libgettext.h"
 #include "message.h"
@@ -66,9 +67,6 @@ static char *output_dir;
 /* If nonzero omit header with information about this run.  */
 static int omit_header;
 
-/* String containing name the program is called with.  */
-const char *program_name;
-
 /* These variables control which messages are selected.  */
 static int more_than = -1;
 static int less_than = -1;
@@ -106,7 +104,6 @@ static void usage PARAMS ((int status))
        __attribute__ ((noreturn))
 #endif
 ;
-static void error_print PARAMS ((void));
 static string_list_ty *read_name_from_file PARAMS ((const char *__file_name));
 static void extract_constructor PARAMS ((po_ty *__that));
 static void extract_directive_domain PARAMS ((po_ty *__that, char *__name));
@@ -147,7 +144,7 @@ main (argc, argv)
 
   /* Set program name for messages.  */
   program_name = argv[0];
-  error_print_progname = error_print;
+  error_print_progname = maybe_print_progname;
 
 #ifdef HAVE_SETLOCALE
   /* Set locale via LC_ALL.  */
@@ -452,15 +449,6 @@ Informative output:\n\
 }
 
 
-/* The address of this function will be assigned to the hook in the error
-   functions.  */
-static void
-error_print ()
-{
-  /* We don't want the program name to be printed in messages.  */
-}
-
-
 /* Read list of files to process from file.  */
 static string_list_ty *
 read_name_from_file (file_name)
index e175597d997b121e40be87b571424b8c4dd98a3f..b75f5d282dac86e04bf5e4127dc621d11572c95a 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "dir-list.h"
 #include "error.h"
+#include "progname.h"
 #include "getline.h"
 #include "printf.h"
 #include <system.h>
@@ -101,9 +102,6 @@ static int no_hash_table;
 /* Specifies name of the output file.  */
 static const char *output_file_name;
 
-/* String containing name the program is called with.  */
-const char *program_name;
-
 /* We may have more than one input file.  Domains with same names in
    different files have to merged.  So we need a list of tables for
    each output file.  */
@@ -167,7 +165,6 @@ static void usage PARAMS ((int status))
        __attribute__ ((noreturn))
 #endif
 ;
-static void error_print PARAMS ((void));
 static void grammar PARAMS ((char *__filename));
 static void format_constructor PARAMS ((po_ty *__that));
 static void format_directive_domain PARAMS ((po_ty *__pop, char *__name));
@@ -205,7 +202,7 @@ main (argc, argv)
 
   /* Set program name for messages.  */
   program_name = argv[0];
-  error_print_progname = error_print;
+  error_print_progname = maybe_print_progname;
   error_one_per_line = 1;
   exit_status = EXIT_SUCCESS;
 
@@ -465,16 +462,6 @@ new_domain (name)
 }
 
 
-/* The address of this function will be assigned to the hook in the error
-   functions.  */
-static void
-error_print ()
-{
-  /* We don't want the program name to be printed in messages.  Emacs'
-     compile.el does not like this.  */
-}
-
-
 /* Prepare for first message.  */
 static void
 format_constructor (that)
@@ -572,12 +559,16 @@ format_directive_message (that, msgid_string, msgid_pos, msgid_plural,
       || (!include_all && this->is_fuzzy && msgid_string[0] != '\0'))
     {
       if (verbose_level > 1)
-       /* We don't change the exit status here because this is really
-          only an information.  */
-       error_at_line (0, 0, msgstr_pos->file_name, msgstr_pos->line_number,
-                      (msgstr_string[0] == '\0'
-                       ? _("empty `msgstr' entry ignored")
-                       : _("fuzzy `msgstr' entry ignored")));
+       {
+         /* We don't change the exit status here because this is really
+            only an information.  */
+         error_with_progname = 0;
+         error_at_line (0, 0, msgstr_pos->file_name, msgstr_pos->line_number,
+                        (msgstr_string[0] == '\0'
+                         ? _("empty `msgstr' entry ignored")
+                         : _("fuzzy `msgstr' entry ignored")));
+         error_with_progname = 1;
+       }
 
       /* Increment counter for fuzzy/untranslated messages.  */
       if (msgstr_string[0] == '\0')
@@ -954,17 +945,21 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos,
     {
       if (TEST_NEWLINE(msgid_plural) != has_newline)
        {
+         error_with_progname = 0;
          error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                         _("\
 `msgid' and `msgid_plural' entries do not both begin with '\\n'"));
+         error_with_progname = 1;
          exit_status = EXIT_FAILURE;
        }
       for (p = msgstr, i = 0; p < msgstr + msgstr_len; p += strlen (p) + 1, i++)
        if (TEST_NEWLINE(p) != has_newline)
          {
+           error_with_progname = 0;
            error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                           _("\
 `msgid' and `msgstr[%u]' entries do not both begin with '\\n'"), i);
+           error_with_progname = 1;
            exit_status = EXIT_FAILURE;
          }
     }
@@ -972,9 +967,11 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos,
     {
       if (TEST_NEWLINE(msgstr) != has_newline)
        {
+         error_with_progname = 0;
          error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                         _("\
 `msgid' and `msgstr' entries do not both begin with '\\n'"));
+         error_with_progname = 1;
          exit_status = EXIT_FAILURE;
        }
     }
@@ -987,17 +984,21 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos,
     {
       if (TEST_NEWLINE(msgid_plural) != has_newline)
        {
+         error_with_progname = 0;
          error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                         _("\
 `msgid' and `msgid_plural' entries do not both end with '\\n'"));
+         error_with_progname = 1;
          exit_status = EXIT_FAILURE;
        }
       for (p = msgstr, i = 0; p < msgstr + msgstr_len; p += strlen (p) + 1, i++)
        if (TEST_NEWLINE(p) != has_newline)
          {
+           error_with_progname = 0;
            error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                           _("\
 `msgid' and `msgstr[%u]' entries do not both end with '\\n'"), i);
+           error_with_progname = 1;
            exit_status = EXIT_FAILURE;
          }
     }
@@ -1005,9 +1006,11 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos,
     {
       if (TEST_NEWLINE(msgstr) != has_newline)
        {
+         error_with_progname = 0;
          error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                         _("\
 `msgid' and `msgstr' entries do not both end with '\\n'"));
+         error_with_progname = 1;
          exit_status = EXIT_FAILURE;
        }
     }
@@ -1021,9 +1024,11 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos,
       nstrfmts = parse_printf_format (msgstr, 0, NULL);
       if (nidfmts != nstrfmts)
        {
+         error_with_progname = 0;
          error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
                         _("\
 number of format specifications in `msgid' and `msgstr' does not match"));
+         error_with_progname = 1;
          exit_status = EXIT_FAILURE;
        }
       else
@@ -1038,10 +1043,12 @@ number of format specifications in `msgid' and `msgstr' does not match"));
          for (cnt = 0; cnt < nidfmts; ++cnt)
            if (id_args[cnt] != str_args[cnt])
              {
+               error_with_progname = 0;
                error_at_line (0, 0, msgid_pos->file_name,
                               msgid_pos->line_number, _("\
 format specifications for argument %lu are not the same"),
                               (unsigned long) (cnt + 1));
+               error_with_progname = 1;
                exit_status = EXIT_FAILURE;
              }
        }
index a98d4d6f5ae9941a33b8ca534eacdf8a4882bd9e..c8e5145a1990a06077ba4a1c34e6e85b31284cd3 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "dir-list.h"
 #include "error.h"
+#include "progname.h"
 #include "message.h"
 #include "read-po.h"
 #include "write-po.h"
@@ -38,9 +39,6 @@
 #define _(str) gettext (str)
 
 
-/* String containing name the program is called with.  */
-const char *program_name;
-
 /* If non-zero do not print unneeded messages.  */
 static int quiet;
 
@@ -80,7 +78,6 @@ static const struct option long_options[] =
 
 /* Prototypes for local functions.  */
 static void usage PARAMS ((int __status));
-static void error_print PARAMS ((void));
 static message_list_ty *merge PARAMS ((const char *__fn1, const char *__fn2));
 static void compendium PARAMS ((const char *__filename));
 
@@ -100,9 +97,9 @@ main (argc, argv)
 
   /* Set program name for messages.  */
   program_name = argv[0];
+  error_print_progname = maybe_print_progname;
   verbosity_level = 0;
   quiet = 0;
-  error_print_progname = error_print;
   gram_max_allowed_errors = UINT_MAX;
 
 #ifdef HAVE_SETLOCALE
@@ -333,19 +330,6 @@ Informative output:\n\
 }
 
 
-/* The address of this function will be assigned to the hook in the
-   error functions.  */
-static void
-error_print ()
-{
-  /* We don't want the program name to be printed in messages.  Emacs'
-     compile.el does not like this.  */
-
-  /* FIXME Why must this program toady to Emacs?  Why can't compile.el
-     be enhanced to cope with a leading program name?  --PMiller */
-}
-
-
 #define DOT_FREQUENCE 10
 
 static message_list_ty *
index fbb581733a08de9688a842492e7ab5cb963077c0..2b613447c088b247aa727e3822ccab96dad94874 100644 (file)
@@ -31,6 +31,7 @@
 #include "hash.h"
 
 #include "error.h"
+#include "progname.h"
 #include "getline.h"
 #include "printf.h"
 #include <system.h>
@@ -48,9 +49,6 @@ extern int errno;
 #endif
 
 
-/* String containing name the program is called with.  */
-const char *program_name;
-
 /* Force output of PO file even if empty.  */
 static int force_po;
 
@@ -78,7 +76,6 @@ static enum { MO_LITTLE_ENDIAN, MO_BIG_ENDIAN } endian;
 
 /* Prototypes for local functions.  */
 static void usage PARAMS ((int __status));
-static void error_print PARAMS ((void));
 static nls_uint32 read32 PARAMS ((FILE *__fp, const char *__fn));
 static void seek32 PARAMS ((FILE *__fp, const char *__fn, long __offset));
 static char *string32 PARAMS ((FILE *__fp, const char *__fn, long __offset,
@@ -101,7 +98,7 @@ main (argc, argv)
 
   /* Set program name for messages.  */
   program_name = argv[0];
-  error_print_progname = error_print;
+  error_print_progname = maybe_print_progname;
 
 #ifdef HAVE_SETLOCALE
   /* Set locale via LC_ALL.  */
@@ -265,16 +262,6 @@ Informative output:\n\
 }
 
 
-/* The address of this function will be assigned to the hook in the error
-   functions.  */
-static void
-error_print ()
-{
-  /* We don't want the program name to be printed in messages.  Emacs'
-     compile.el does not like this.  */
-}
-
-
 /* This function reads a 32-bit number from the file, and assembles it
    according to the current ``endian'' setting.  */
 static nls_uint32
index d46c66619c25079aaf795de1fea2590f1f038c52..0ad49d8c6ef7c9dec00753127e66ad1f8fabf66e 100644 (file)
@@ -132,10 +132,14 @@ po_gram_error (fmt, va_alist)
 
   vasprintf (&buffer, fmt, ap);
   va_end (ap);
+  error_with_progname = 0;
   error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, "%s", buffer);
+  error_with_progname = 1;
 # else
+  error_with_progname = 0;
   error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, fmt,
                 a1, a2, a3, a4, a5, a6, a7, a8);
+  error_with_progname = 1;
 # endif
 
   /* Some messages need more than one line.  Continuation lines are
@@ -170,10 +174,14 @@ po_gram_error_at_line (pp, fmt, va_alist)
 
   vasprintf (&buffer, fmt, ap);
   va_end (ap);
+  error_with_progname = 0;
   error_at_line (0, 0, pp->file_name, pp->line_number, "%s", buffer);
+  error_with_progname = 1;
 # else
+  error_with_progname = 0;
   error_at_line (0, 0, pp->file_name, pp->line_number, fmt,
                 a1, a2, a3, a4, a5, a6, a7, a8);
+  error_with_progname = 1;
 # endif
 
   /* Some messages need more than one line, or more than one location.
index 11a1b1c096f8f0b82b965bc014aac03a95d75604..0ade9e408a42bbf850dd652f12e2cab544bef35c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <sys/types.h>
 #include "error.h"
+#include "progname.h"
 #include "pos.h"
 
 /* Lexical analyzer for reading PO files.  */
@@ -66,8 +67,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int __flag));
 
 # define po_gram_error(fmt, ...)                                           \
   do {                                                                     \
+    error_with_progname = 0;                                               \
     error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number,         \
                    fmt, __VA_ARGS__);                                      \
+    error_with_progname = 1;                                               \
     if (*fmt == '.')                                                       \
       --error_message_count;                                               \
     else if (error_message_count >= gram_max_allowed_errors)               \
@@ -80,8 +83,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int __flag));
 
 # define po_gram_error_at_line(pos, fmt, ...)                              \
   do {                                                                     \
+    error_with_progname = 0;                                               \
     error_at_line (0, 0, (pos)->file_name, (pos)->line_number,             \
                    fmt, __VA_ARGS__);                                      \
+    error_with_progname = 1;                                               \
     if (*fmt == '.')                                                       \
       --error_message_count;                                               \
     else if (error_message_count >= gram_max_allowed_errors)               \
@@ -96,8 +101,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int __flag));
 
 # define po_gram_error(fmt, args...)                                       \
   do {                                                                     \
+    error_with_progname = 0;                                               \
     error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number,         \
                    fmt, ## args);                                          \
+    error_with_progname = 1;                                               \
     if (*fmt == '.')                                                       \
       --error_message_count;                                               \
     else if (error_message_count >= gram_max_allowed_errors)               \
@@ -110,8 +117,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int __flag));
 
 # define po_gram_error_at_line(pos, fmt, args...)                          \
   do {                                                                     \
+    error_with_progname = 0;                                               \
     error_at_line (0, 0, (pos)->file_name, (pos)->line_number,             \
                    fmt, ## args);                                          \
+    error_with_progname = 1;                                               \
     if (*fmt == '.')                                                       \
       --error_message_count;                                               \
     else if (error_message_count >= gram_max_allowed_errors)               \
index 84b111a0fbd2b34e1164acdb2660c74664db8208..08b31581869e3b5529df91aed4214e64d668b968 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "dir-list.h"
 #include "error.h"
+#include "progname.h"
 #include "system.h"
 #include "libgettext.h"
 #include "hash.h"
@@ -873,8 +874,10 @@ phase5_get (tp)
          c = phase7_getc ();
          if (c == P7_NEWLINE)
            {
+             error_with_progname = 0;
              error (0, 0, _("%s:%d: warning: unterminated character constant"),
                logical_file_name, line_number - 1);
+             error_with_progname = 1;
              phase7_ungetc ('\n');
              break;
            }
@@ -895,8 +898,10 @@ phase5_get (tp)
          c = phase7_getc ();
          if (c == P7_NEWLINE)
            {
+             error_with_progname = 0;
              error (0, 0, _("%s:%d: warning: unterminated string literal"),
                logical_file_name, line_number - 1);
+             error_with_progname = 1;
              phase7_ungetc ('\n');
              break;
            }
index abfba61845141b5408280e296ff8fae2a02cbd79..ce1e716d741d5fac740e56af1ba106fe1c616246 100644 (file)
@@ -41,6 +41,7 @@ extern int errno;
 
 #include "dir-list.h"
 #include "error.h"
+#include "progname.h"
 #include "hash.h"
 #include "getline.h"
 #include "system.h"
@@ -102,9 +103,6 @@ static char *output_dir;
 /* If nonzero omit header with information about this run.  */
 static int omit_header;
 
-/* String containing name the program is called with.  */
-const char *program_name;
-
 /* Long options.  */
 static const struct option long_options[] =
 {
@@ -149,7 +147,6 @@ static void usage PARAMS ((int status))
        __attribute__ ((noreturn))
 #endif
 ;
-static void error_print PARAMS ((void));
 static string_list_ty *read_name_from_file PARAMS ((const char *__file_name));
 static void exclude_directive_domain PARAMS ((po_ty *__pop, char *__name));
 static void exclude_directive_message PARAMS ((po_ty *__pop, char *__msgid,
@@ -217,7 +214,7 @@ main (argc, argv)
 
   /* Set program name for messages.  */
   program_name = argv[0];
-  error_print_progname = error_print;
+  error_print_progname = maybe_print_progname;
 
 #ifdef HAVE_SETLOCALE
   /* Set locale via LC_ALL.  */
@@ -603,15 +600,6 @@ Informative output:\n\
 }
 
 
-/* The address of this function will be assigned to the hook in the error
-   functions.  */
-static void
-error_print ()
-{
-  /* We don't want the program name to be printed in messages.  */
-}
-
-
 /* Read list of files to process from file.  */
 static string_list_ty *
 read_name_from_file (file_name)
@@ -944,9 +932,11 @@ scan_c_file (filename, mlp)
           {
             if (commas_to_skip == 0)
               {
+                error_with_progname = 0;
                 error (0, 0,
                        _("%s:%d: warning: keyword nested in keyword arg"),
                        token.file_name, token.line_number);
+                error_with_progname = 1;
                 continue;
               }
 
@@ -954,9 +944,11 @@ scan_c_file (filename, mlp)
                potentially unbounded stack.  We haven't run across an
                example that needs this functionality yet.  For now,
                we punt and forget the outer keyword.  */
+            error_with_progname = 0;
             error (0, 0,
                    _("%s:%d: warning: keyword between outer keyword and its arg"),
                    token.file_name, token.line_number);
+            error_with_progname = 1;
           }
         commas_to_skip = token.argnum1 - 1;
         plural_commas = (token.argnum2 > token.argnum1