bug-gnulib
[Top][All Lists]
Advanced

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

Re: [bug-gnulib] standards.texi error function


From: Paul Eggert
Subject: Re: [bug-gnulib] standards.texi error function
Date: Tue, 07 Dec 2004 13:06:39 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Richard Stallman <address@hidden> writes:

> Many programs don't use long long int.  Does our old recommendation
> have problems in other cases too?

The main types I'm concerned about are long long int (or types like
off_t that might be integer types that are wider than long int), and
long double.  Perhaps "double" and "float" as well, on hosts that pass
floating-point arguments in separate registers.

Also there's one minor problem with the old recommendation: "error"
should have a return type.


> What does it look like to use the gnulib error module?

Typically one copies these files from gnulib to your own package:

  lib/error.h
  lib/error.c
  lib/gettext.h
  m4/error.m4
  m4/strerror_r.m4

puts "gl_ERROR" into configure.in, and (if necessary) adjusts one's
usage of "error" to match the glibc API.  If you're not using aclocal,
you copy the contents of the abovementioned m4 files into configure.in
instead of copying the files.

For example, here is a patch to CVS GNU Emacs that adjusts
emacs/lib-src/*.c to use the gnulib error module.  I don't think this
package is necessary for Emacs, since it never prints values of the
troublesome types.  Also, the patch is not quite correct, since we'd
need to adjust how LIBOBJS is handled.  I'm sending it mostly to
illustrate the sort of things that are needed.  Most of this patch
consists of copies of the above files.

Index: configure.in
===================================================================
RCS file: /cvsroot/emacs/emacs/configure.in,v
retrieving revision 1.380
diff -p -c -r1.380 configure.in
*** configure.in        7 Dec 2004 15:42:19 -0000       1.380
--- configure.in        7 Dec 2004 20:56:36 -0000
*************** AC_PROG_MAKE_SET
*** 1596,1601 ****
--- 1596,1670 ----
  dnl checks for operating system services
  AC_SYS_LONG_FILE_NAMES
  
+ #### Configure the error module.
+ 
+ # This is a copy of gnulib/lib/error.m4.
+ #serial 10
+ 
+ AC_DEFUN([gl_ERROR],
+ [
+   AC_FUNC_ERROR_AT_LINE
+   dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]).
+   gl_PREREQ_ERROR
+ ])
+ 
+ # Prerequisites of lib/error.c.
+ AC_DEFUN([gl_PREREQ_ERROR],
+ [
+   AC_REQUIRE([AC_FUNC_STRERROR_R])
+   :
+ ])
+ # End of copy of gnulib/lib/error.m4.
+ 
+ # This is a copy of gnulib/lib/strerror_r.m4.
+ #serial 1003
+ # Experimental replacement for the function in the latest CVS autoconf.
+ # Use with the error.c file in ../lib.
+ 
+ undefine([AC_FUNC_STRERROR_R])
+ 
+ # AC_FUNC_STRERROR_R
+ # ------------------
+ AC_DEFUN([AC_FUNC_STRERROR_R],
+ [AC_CHECK_DECLS([strerror_r])
+ AC_CHECK_FUNCS([strerror_r])
+ AC_CACHE_CHECK([whether strerror_r returns char *],
+                ac_cv_func_strerror_r_char_p,
+    [
+     ac_cv_func_strerror_r_char_p=no
+     if test $ac_cv_have_decl_strerror_r = yes; then
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+       [[
+         char buf[100];
+         char x = *strerror_r (0, buf, sizeof buf);
+         char *p = strerror_r (0, buf, sizeof buf);
+       ]])],
+                       ac_cv_func_strerror_r_char_p=yes)
+     else
+       # strerror_r is not declared.  Choose between
+       # systems that have relatively inaccessible declarations for the
+       # function.  BeOS and DEC UNIX 4.0 fall in this category, but the
+       # former has a strerror_r that returns char*, while the latter
+       # has a strerror_r that returns `int'.
+       # This test should segfault on the DEC system.
+       AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+       extern char *strerror_r ();],
+       [[char buf[100];
+         char x = *strerror_r (0, buf, sizeof buf);
+         exit (!isalpha (x));]])],
+                     ac_cv_func_strerror_r_char_p=yes, , :)
+     fi
+   ])
+ if test $ac_cv_func_strerror_r_char_p = yes; then
+   AC_DEFINE([STRERROR_R_CHAR_P], 1,
+           [Define to 1 if strerror_r returns char *.])
+ fi
+ ])# AC_FUNC_STRERROR_R
+ # End of copy of gnulib/lib/strerror_r.m4.
+ 
+ gl_ERROR
+ 
+ 
  #### Choose a window system.
  
  AC_PATH_X
Index: lib-src/Makefile.in
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/Makefile.in,v
retrieving revision 1.141
diff -p -c -r1.141 Makefile.in
*** lib-src/Makefile.in 11 Jun 2004 02:39:49 -0000      1.141
--- lib-src/Makefile.in 7 Dec 2004 20:56:36 -0000
*************** test-distrib${EXEEXT}: ${srcdir}/test-di
*** 382,387 ****
--- 382,392 ----
        $(CC) ${ALL_CFLAGS} -o test-distrib ${srcdir}/test-distrib.c
        ./test-distrib ${srcdir}/testfile
  
+ ERROROBJS = error.o
+ ERRORDEPS = $(ERROROBJS) ${srcdir}/error.h
+ error.o: ${srcdir}/error.c ${srcdir}/error.h ${srcdir}/gettext.h 
../src/config.h
+       $(CC) -c ${CPP_CFLAGS} ${srcdir}/error.c
+ 
  GETOPTOBJS = getopt.o getopt1.o
  GETOPTDEPS = $(GETOPTOBJS) ${srcdir}/getopt.h
  getopt.o: ${srcdir}/getopt.c ${srcdir}/getopt.h
*************** REGEXPDEPS = $(REGEXPOBJ) $(srcdir)/../s
*** 400,407 ****
  regex.o: $(srcdir)/../src/regex.c $(srcdir)/../src/regex.h ../src/config.h
        ${CC} -c ${BASE_CFLAGS} -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER 
${srcdir}/../src/regex.c
  
! etags${EXEEXT}: ${srcdir}/etags.c $(GETOPTDEPS) $(REGEXPDEPS) ../src/config.h
!       $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" ${srcdir}/etags.c 
$(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o etags
  
  ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(GETOPTDEPS) ../src/config.h
        $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" ${srcdir}/ebrowse.c 
$(GETOPTOBJS) $(LOADLIBES) -o ebrowse
--- 405,412 ----
  regex.o: $(srcdir)/../src/regex.c $(srcdir)/../src/regex.h ../src/config.h
        ${CC} -c ${BASE_CFLAGS} -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER 
${srcdir}/../src/regex.c
  
! etags${EXEEXT}: ${srcdir}/etags.c $(ERRORDEPS) $(GETOPTDEPS) $(REGEXPDEPS) 
../src/config.h
!       $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" ${srcdir}/etags.c 
$(ERROROBJS) $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o etags
  
  ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(GETOPTDEPS) ../src/config.h
        $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" ${srcdir}/ebrowse.c 
$(GETOPTOBJS) $(LOADLIBES) -o ebrowse
*************** ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(
*** 409,434 ****
  /* We depend on etags to assure that parallel makes don\'t write two
     etags.o files on top of each other.  */
  ctags${EXEEXT}: etags${EXEEXT}
!       $(CC) ${ALL_CFLAGS} -DCTAGS -DVERSION="\"${version}\"" 
${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o ctags
  
  profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h
        $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c $(LOADLIBES) -o profile
  
! make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h
!       $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) -o 
make-docfile
  
  digest-doc${EXEEXT}: ${srcdir}/digest-doc.c
        $(CC) ${ALL_CFLAGS} ${srcdir}/digest-doc.c $(LOADLIBES) -o digest-doc
  
! sorted-doc${EXEEXT}: ${srcdir}/sorted-doc.c
!       $(CC) ${ALL_CFLAGS} ${srcdir}/sorted-doc.c $(LOADLIBES) -o sorted-doc
  
  b2m${EXEEXT}: ${srcdir}/b2m.c ../src/config.h $(GETOPTDEPS)
        $(CC) ${ALL_CFLAGS} ${srcdir}/b2m.c  -DVERSION="\"${version}\"" \
           $(GETOPTOBJS) $(LOADLIBES) -o b2m
  
! movemail${EXEEXT}: movemail.o pop.o $(GETOPTDEPS)
!       $(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o $(GETOPTOBJS) 
$(LOADLIBES) $(LIBS_MAIL) $(LIBS_MOVE) -o movemail
  
  movemail.o: ${srcdir}/movemail.c ../src/config.h
        $(CC) -c ${CPP_CFLAGS} -Demacs ${MOVE_FLAGS} ${srcdir}/movemail.c
--- 414,439 ----
  /* We depend on etags to assure that parallel makes don\'t write two
     etags.o files on top of each other.  */
  ctags${EXEEXT}: etags${EXEEXT}
!       $(CC) ${ALL_CFLAGS} -DCTAGS -DVERSION="\"${version}\"" 
${srcdir}/etags.c $(ERROROBJS) $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o ctags
  
  profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h
        $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c $(LOADLIBES) -o profile
  
! make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h $(ERRORDEPS)
!       $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(ERROROBJS) $(LOADLIBES) 
-o make-docfile
  
  digest-doc${EXEEXT}: ${srcdir}/digest-doc.c
        $(CC) ${ALL_CFLAGS} ${srcdir}/digest-doc.c $(LOADLIBES) -o digest-doc
  
! sorted-doc${EXEEXT}: ${srcdir}/sorted-doc.c $(ERRORDEPS)
!       $(CC) ${ALL_CFLAGS} ${srcdir}/sorted-doc.c $(ERROROBJS) $(LOADLIBES) -o 
sorted-doc
  
  b2m${EXEEXT}: ${srcdir}/b2m.c ../src/config.h $(GETOPTDEPS)
        $(CC) ${ALL_CFLAGS} ${srcdir}/b2m.c  -DVERSION="\"${version}\"" \
           $(GETOPTOBJS) $(LOADLIBES) -o b2m
  
! movemail${EXEEXT}: movemail.o pop.o $(ERRORDEPS) $(GETOPTDEPS)
!       $(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o $(ERROROBJS) 
$(GETOPTOBJS) $(LOADLIBES) $(LIBS_MAIL) $(LIBS_MOVE) -o movemail
  
  movemail.o: ${srcdir}/movemail.c ../src/config.h
        $(CC) -c ${CPP_CFLAGS} -Demacs ${MOVE_FLAGS} ${srcdir}/movemail.c
*************** movemail.o: ${srcdir}/movemail.c ../src/
*** 436,446 ****
  pop.o: ${srcdir}/pop.c  ../src/config.h
        $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c
  
! cvtmail${EXEEXT}: ${srcdir}/cvtmail.c
!       $(CC) ${ALL_CFLAGS} ${srcdir}/cvtmail.c $(LOADLIBES) -o cvtmail
  
! fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h
!       $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail
  
  yow${EXEEXT}: ${srcdir}/yow.c ../src/epaths.h
        $(CC) ${ALL_CFLAGS} ${srcdir}/yow.c $(LOADLIBES) -o yow
--- 441,451 ----
  pop.o: ${srcdir}/pop.c  ../src/config.h
        $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c
  
! cvtmail${EXEEXT}: ${srcdir}/cvtmail.c $(ERRORDEPS)
!       $(CC) ${ALL_CFLAGS} ${srcdir}/cvtmail.c $(ERROROBJS) $(LOADLIBES) -o 
cvtmail
  
! fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h $(ERRORDEPS)
!       $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(ERROROBJS) $(LOADLIBES) -o 
fakemail
  
  yow${EXEEXT}: ${srcdir}/yow.c ../src/epaths.h
        $(CC) ${ALL_CFLAGS} ${srcdir}/yow.c $(LOADLIBES) -o yow
Index: lib-src/cvtmail.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/cvtmail.c,v
retrieving revision 1.13
diff -p -c -r1.13 cvtmail.c
*** lib-src/cvtmail.c   8 May 2004 15:23:24 -0000       1.13
--- lib-src/cvtmail.c   7 Dec 2004 20:56:36 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 38,48 ****
--- 38,51 ----
  #endif
  
  #include <stdio.h>
+ #include "error.h"
  
  #ifndef HAVE_STDLIB_H
  char *getenv ();
  #endif
  
+ char *program_name;
+ 
  char *xmalloc __P ((unsigned));
  char *xrealloc __P ((char *, unsigned));
  void skip_to_lf __P ((FILE *));
*************** main (argc, argv)
*** 66,71 ****
--- 69,75 ----
    char name[14];
    int c;
  
+   program_name = argv[0];
    hd = (char *) getenv ("HOME");
  
    md = (char *) xmalloc (strlen (hd) + 10);
*************** skip_to_lf (stream)
*** 131,154 ****
      ;
  }
  
- 
- void
- error (s1, s2)
-      char *s1, *s2;
- {
-   fprintf (stderr, "cvtmail: ");
-   fprintf (stderr, s1, s2);
-   fprintf (stderr, "\n");
- }
- 
  /* Print error message and exit.  */
  
  void
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (s1, s2);
!   exit (EXIT_FAILURE);
  }
  
  void
--- 135,147 ----
      ;
  }
  
  /* Print error message and exit.  */
  
  void
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (EXIT_FAILURE, 0, s1, s2);
  }
  
  void
Index: lib-src/etags.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/etags.c,v
retrieving revision 3.43
diff -p -c -r3.43 etags.c
*** lib-src/etags.c     16 Nov 2004 23:25:58 -0000      3.43
--- lib-src/etags.c     7 Dec 2004 20:56:36 -0000
*************** If you want regular expression support, 
*** 217,222 ****
--- 217,224 ----
  #define lowcase(c)    tolower (CHAR(c))
  #define upcase(c)     toupper (CHAR(c))
  
+ #include "error.h"
+ 
  
  /*
   *    xnew, xrnew -- allocate, reallocate storage
*************** static void analyse_regex __P((char *));
*** 378,384 ****
  static void free_regexps __P((void));
  static void regex_tag_multiline __P((void));
  #endif /* ETAGS_REGEXPS */
- static void error __P((const char *, const char *));
  static void suggest_asking_for_help __P((void));
  void fatal __P((char *, char *));
  static void pfatal __P((char *));
--- 380,385 ----
*************** static PTR xrealloc __P((char *, unsigne
*** 419,425 ****
  static char searchar = '/';   /* use /.../ searches */
  
  static char *tagfile;         /* output file */
! static char *progname;                /* name this program was invoked with */
  static char *cwd;             /* current working directory */
  static char *tagfiledir;      /* directory of tagfile */
  static FILE *tagf;            /* ioptr for tags file */
--- 420,426 ----
  static char searchar = '/';   /* use /.../ searches */
  
  static char *tagfile;         /* output file */
! char *program_name;           /* name this program was invoked with */
  static char *cwd;             /* current working directory */
  static char *tagfiledir;      /* directory of tagfile */
  static FILE *tagf;            /* ioptr for tags file */
*************** print_help (argbuffer)
*** 870,876 ****
  
    printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
  \n\
! These are the options accepted by %s.\n", progname, progname);
    if (LONG_OPTIONS)
      puts ("You may use unambiguous abbreviations for the long option names.");
    else
--- 871,877 ----
  
    printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
  \n\
! These are the options accepted by %s.\n", program_name, program_name);
    if (LONG_OPTIONS)
      puts ("You may use unambiguous abbreviations for the long option names.");
    else
*************** gfnames (arg, p_error)
*** 1112,1118 ****
  system (cmd)
       char *cmd;
  {
!   error ("%s", "system() function not implemented under VMS");
  }
  #endif
  
--- 1113,1119 ----
  system (cmd)
       char *cmd;
  {
!   error (0, 0, "%s", "system() function not implemented under VMS");
  }
  #endif
  
*************** main (argc, argv)
*** 1158,1164 ****
    _fmode = O_BINARY;   /* all of files are treated as binary files */
  #endif /* DOS_NT */
  
!   progname = argv[0];
    nincluded_files = 0;
    included_files = xnew (argc, char *);
    current_arg = 0;
--- 1159,1165 ----
    _fmode = O_BINARY;   /* all of files are treated as binary files */
  #endif /* DOS_NT */
  
!   program_name = argv[0];
    nincluded_files = 0;
    included_files = xnew (argc, char *);
    current_arg = 0;
*************** main (argc, argv)
*** 1222,1228 ****
        case 'o':
        if (tagfile)
          {
!           error ("-o option may only be given once.", (char *)NULL);
            suggest_asking_for_help ();
            /* NOTREACHED */
          }
--- 1223,1229 ----
        case 'o':
        if (tagfile)
          {
!           error (0, 0, "-o option may only be given once.");
            suggest_asking_for_help ();
            /* NOTREACHED */
          }
*************** main (argc, argv)
*** 1300,1306 ****
  
    if (nincluded_files == 0 && file_count == 0)
      {
!       error ("no input files specified.", (char *)NULL);
        suggest_asking_for_help ();
        /* NOTREACHED */
      }
--- 1301,1307 ----
  
    if (nincluded_files == 0 && file_count == 0)
      {
!       error (0, 0, "no input files specified.");
        suggest_asking_for_help ();
        /* NOTREACHED */
      }
*************** main (argc, argv)
*** 1370,1376 ****
            {
              if (got_err)
                {
!                 error ("can't find file %s\n", this_file);
                  argc--, argv++;
                }
              else
--- 1371,1377 ----
            {
              if (got_err)
                {
!                 error (0, 0, "can't find file %s\n", this_file);
                  argc--, argv++;
                }
              else
*************** get_language_from_langname (name)
*** 1526,1538 ****
    language *lang;
  
    if (name == NULL)
!     error ("empty language name", (char *)NULL);
    else
      {
        for (lang = lang_names; lang->name != NULL; lang++)
        if (streq (name, lang->name))
          return lang;
!       error ("unknown language \"%s\"", name);
      }
  
    return NULL;
--- 1527,1539 ----
    language *lang;
  
    if (name == NULL)
!     error (0, 0, "empty language name");
    else
      {
        for (lang = lang_names; lang->name != NULL; lang++)
        if (streq (name, lang->name))
          return lang;
!       error (0, 0, "unknown language \"%s\"", name);
      }
  
    return NULL;
*************** process_file_name (file, lang)
*** 1617,1623 ****
    canonicalize_filename (file);
    if (streq (file, tagfile) && !streq (tagfile, "-"))
      {
!       error ("skipping inclusion of %s in self.", file);
        return;
      }
    if ((compr = get_compressor_from_suffix (file, &ext)) == NULL)
--- 1618,1624 ----
    canonicalize_filename (file);
    if (streq (file, tagfile) && !streq (tagfile, "-"))
      {
!       error (0, 0, "skipping inclusion of %s in self.", file);
        return;
      }
    if ((compr = get_compressor_from_suffix (file, &ext)) == NULL)
*************** process_file_name (file, lang)
*** 1691,1697 ****
  
    if (!S_ISREG (stat_buf.st_mode))
      {
!       error ("skipping %s: it is not a regular file.", real_name);
        goto cleanup;
      }
    if (real_name == compressed_name)
--- 1692,1698 ----
  
    if (!S_ISREG (stat_buf.st_mode))
      {
!       error (0, 0, "skipping %s: it is not a regular file.", real_name);
        goto cleanup;
      }
    if (real_name == compressed_name)
*************** put_entries (np)
*** 2333,2339 ****
        {
          /* Ctags mode */
          if (np->name == NULL)
!           error ("internal error: NULL name in ctags mode.", (char *)NULL);
  
          if (cxref_style)
            {
--- 2334,2340 ----
        {
          /* Ctags mode */
          if (np->name == NULL)
!           error (0, 0, "internal error: NULL name in ctags mode.");
  
          if (cxref_style)
            {
*************** consider_token (str, len, c, c_extp, bra
*** 2879,2885 ****
       case dignorerest:
         return FALSE;
       default:
!        error ("internal error: definedef value.", (char *)NULL);
       }
  
     /*
--- 2880,2886 ----
       case dignorerest:
         return FALSE;
       default:
!        error (0, 0, "internal error: definedef value.");
       }
  
     /*
*************** analyse_regex (regex_arg)
*** 5774,5780 ****
        for (cp = lang_name; *cp != '}'; cp++)
          if (*cp == '\0')
            {
!             error ("unterminated language name in regex: %s", regex_arg);
              return;
            }
        *cp++ = '\0';
--- 5775,5781 ----
        for (cp = lang_name; *cp != '}'; cp++)
          if (*cp == '\0')
            {
!             error (0, 0, "unterminated language name in regex: %s", 
regex_arg);
              return;
            }
        *cp++ = '\0';
*************** add_regex (regexp_pattern, lang)
*** 5813,5831 ****
  
    if (strlen(regexp_pattern) < 3)
      {
!       error ("null regexp", (char *)NULL);
        return;
      }
    sep = regexp_pattern[0];
    name = scan_separators (regexp_pattern);
    if (name == NULL)
      {
!       error ("%s: unterminated regexp", regexp_pattern);
        return;
      }
    if (name[1] == sep)
      {
!       error ("null name for regexp \"%s\"", regexp_pattern);
        return;
      }
    modifiers = scan_separators (name);
--- 5814,5832 ----
  
    if (strlen(regexp_pattern) < 3)
      {
!       error (0, 0, "null regexp");
        return;
      }
    sep = regexp_pattern[0];
    name = scan_separators (regexp_pattern);
    if (name == NULL)
      {
!       error (0, 0, "%s: unterminated regexp", regexp_pattern);
        return;
      }
    if (name[1] == sep)
      {
!       error (0, 0, "null name for regexp \"%s\"", regexp_pattern);
        return;
      }
    modifiers = scan_separators (name);
*************** add_regex (regexp_pattern, lang)
*** 5843,5849 ****
        {
        case 'N':
        if (modifiers == name)
!         error ("forcing explicit tag name but no name, ignoring", NULL);
        force_explicit_name = TRUE;
        break;
        case 'i':
--- 5844,5850 ----
        {
        case 'N':
        if (modifiers == name)
!         error (0, 0, "forcing explicit tag name but no name, ignoring");
        force_explicit_name = TRUE;
        break;
        case 'i':
*************** add_regex (regexp_pattern, lang)
*** 5861,5867 ****
          char wrongmod [2];
          wrongmod[0] = modifiers[0];
          wrongmod[1] = '\0';
!         error ("invalid regexp modifier `%s', ignoring", wrongmod);
        }
        break;
        }
--- 5862,5868 ----
          char wrongmod [2];
          wrongmod[0] = modifiers[0];
          wrongmod[1] = '\0';
!         error (0, 0, "invalid regexp modifier `%s', ignoring", wrongmod);
        }
        break;
        }
*************** add_regex (regexp_pattern, lang)
*** 5892,5898 ****
      free (pat);
    if (err != NULL)
      {
!       error ("%s while compiling pattern", err);
        return;
      }
  
--- 5893,5899 ----
      free (pat);
    if (err != NULL)
      {
!       error (0, 0, "%s while compiling pattern", err);
        return;
      }
  
*************** regex_tag_multiline ()
*** 6017,6023 ****
              /* Some error. */
              if (!rp->error_signaled)
                {
!                 error ("regexp stack overflow while matching \"%s\"",
                         rp->pattern);
                  rp->error_signaled = TRUE;
                }
--- 6018,6024 ----
              /* Some error. */
              if (!rp->error_signaled)
                {
!                 error (0, 0, "regexp stack overflow while matching \"%s\"",
                         rp->pattern);
                  rp->error_signaled = TRUE;
                }
*************** regex_tag_multiline ()
*** 6030,6036 ****
                {
                  if (!rp->error_signaled)
                    {
!                     error ("regexp matches the empty string: \"%s\"",
                             rp->pattern);
                      rp->error_signaled = TRUE;
                    }
--- 6031,6037 ----
                {
                  if (!rp->error_signaled)
                    {
!                     error (0, 0, "regexp matches the empty string: \"%s\"",
                             rp->pattern);
                      rp->error_signaled = TRUE;
                    }
*************** readline (lbp, stream)
*** 6348,6354 ****
              /* Some error. */
              if (!rp->error_signaled)
                {
!                 error ("regexp stack overflow while matching \"%s\"",
                         rp->pattern);
                  rp->error_signaled = TRUE;
                }
--- 6349,6355 ----
              /* Some error. */
              if (!rp->error_signaled)
                {
!                 error (0, 0, "regexp stack overflow while matching \"%s\"",
                         rp->pattern);
                  rp->error_signaled = TRUE;
                }
*************** readline (lbp, stream)
*** 6360,6366 ****
              /* Empty string matched. */
              if (!rp->error_signaled)
                {
!                 error ("regexp matches the empty string: \"%s\"", 
rp->pattern);
                  rp->error_signaled = TRUE;
                }
              break;
--- 6361,6367 ----
              /* Empty string matched. */
              if (!rp->error_signaled)
                {
!                 error (0, 0, "regexp matches the empty string: \"%s\"", 
rp->pattern);
                  rp->error_signaled = TRUE;
                }
              break;
*************** void
*** 6526,6533 ****
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (s1, s2);
!   exit (EXIT_FAILURE);
  }
  
  static void
--- 6527,6533 ----
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (EXIT_FAILURE, 0, s1, s2);
  }
  
  static void
*************** static void
*** 6542,6561 ****
  suggest_asking_for_help ()
  {
    fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
!          progname, LONG_OPTIONS ? "--help" : "-h");
    exit (EXIT_FAILURE);
  }
  
- /* Print error message.  `s1' is printf control string, `s2' is arg for it. */
- static void
- error (s1, s2)
-      const char *s1, *s2;
- {
-   fprintf (stderr, "%s: ", progname);
-   fprintf (stderr, s1, s2);
-   fprintf (stderr, "\n");
- }
- 
  /* Return a newly-allocated string whose contents
     concatenate those of s1, s2, s3.  */
  static char *
--- 6542,6551 ----
  suggest_asking_for_help ()
  {
    fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
!          program_name, LONG_OPTIONS ? "--help" : "-h");
    exit (EXIT_FAILURE);
  }
  
  /* Return a newly-allocated string whose contents
     concatenate those of s1, s2, s3.  */
  static char *
Index: lib-src/fakemail.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/fakemail.c,v
retrieving revision 1.32
diff -p -c -r1.32 fakemail.c
*** lib-src/fakemail.c  8 May 2004 15:23:35 -0000       1.32
--- lib-src/fakemail.c  7 Dec 2004 20:56:36 -0000
*************** main ()
*** 62,67 ****
--- 62,69 ----
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
+ 
+ #include "error.h"
  
  /* Type definitions */
  
*************** struct linebuffer lb;
*** 129,135 ****
  #define MAIL_PROGRAM_NAME "/bin/mail"
  #endif
  
! static char *my_name;
  static char *the_date;
  static char *the_user;
  static line_list file_preface;
--- 131,137 ----
  #define MAIL_PROGRAM_NAME "/bin/mail"
  #endif
  
! char *program_name;
  static char *the_date;
  static char *the_user;
  static line_list file_preface;
*************** static struct passwd *my_entry;
*** 150,175 ****
  
  /* Utilities */
  
- /* Print error message.  `s1' is printf control string, `s2' is arg for it. */
- 
- static void
- error (s1, s2)
-      char *s1, *s2;
- {
-   printf ("%s: ", my_name);
-   printf (s1, s2);
-   printf ("\n");
-   no_problems = false;
- }
- 
  /* Print error message and exit.  */
  
  static void
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (s1, s2);
!   exit (EXIT_FAILURE);
  }
  
  /* Like malloc but get fatal error if memory is exhausted.  */
--- 152,164 ----
  
  /* Utilities */
  
  /* Print error message and exit.  */
  
  static void
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (EXIT_FAILURE, 0, s1, s2);
  }
  
  /* Like malloc but get fatal error if memory is exhausted.  */
*************** setup_files (the_list, field)
*** 548,554 ****
            field += 1;
          *field = '\0';
          if (!open_a_file (start))
!           mail_error ("Could not open file %s", start);
          *field = c;
          if (c != '\0') continue;
        }
--- 537,543 ----
            field += 1;
          *field = '\0';
          if (!open_a_file (start))
!           mail_error (0, 0, "Could not open file %s", start);
          *field = c;
          if (c != '\0') continue;
        }
*************** main (argc, argv)
*** 718,724 ****
      mail_program_name = MAIL_PROGRAM_NAME;
    name_length = strlen (mail_program_name);
  
!   my_name = MY_NAME;
    the_streams = ((stream_list) NULL);
    the_date = ((char *) NULL);
    the_user = ((char *) NULL);
--- 707,713 ----
      mail_program_name = MAIL_PROGRAM_NAME;
    name_length = strlen (mail_program_name);
  
!   program_name = MY_NAME;
    the_streams = ((stream_list) NULL);
    the_date = ((char *) NULL);
    the_user = ((char *) NULL);
Index: lib-src/make-docfile.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/make-docfile.c,v
retrieving revision 1.60
diff -p -c -r1.60 make-docfile.c
*** lib-src/make-docfile.c      9 Nov 2004 11:03:12 -0000       1.60
--- lib-src/make-docfile.c      7 Dec 2004 20:56:36 -0000
*************** int scan_c_file ();
*** 78,100 ****
  #include <unistd.h>
  #endif
  
  /* Stdio stream for output to the DOC file.  */
  FILE *outfile;
  
  /* Name this program was invoked with.  */
! char *progname;
! 
! /* Print error message.  `s1' is printf control string, `s2' is arg for it.  
*/
! 
! /* VARARGS1 */
! void
! error (s1, s2)
!      char *s1, *s2;
! {
!   fprintf (stderr, "%s: ", progname);
!   fprintf (stderr, s1, s2);
!   fprintf (stderr, "\n");
! }
  
  /* Print error message and exit.  */
  
--- 78,90 ----
  #include <unistd.h>
  #endif
  
+ #include "error.h"
+ 
  /* Stdio stream for output to the DOC file.  */
  FILE *outfile;
  
  /* Name this program was invoked with.  */
! char *program_name;
  
  /* Print error message and exit.  */
  
*************** void
*** 103,110 ****
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (s1, s2);
!   exit (EXIT_FAILURE);
  }
  
  /* Like malloc but get fatal error if memory is exhausted.  */
--- 93,99 ----
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (EXIT_FAILURE, 0, s1, s2);
  }
  
  /* Like malloc but get fatal error if memory is exhausted.  */
*************** main (argc, argv)
*** 128,134 ****
    int err_count = 0;
    int first_infile;
  
!   progname = argv[0];
  
    outfile = stdout;
  
--- 117,123 ----
    int err_count = 0;
    int first_infile;
  
!   program_name = argv[0];
  
    outfile = stdout;
  
Index: lib-src/movemail.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/movemail.c,v
retrieving revision 1.80
diff -p -c -r1.80 movemail.c
*** lib-src/movemail.c  8 May 2004 15:23:35 -0000       1.80
--- lib-src/movemail.c  7 Dec 2004 20:56:37 -0000
*************** static char *mail_spool_name ();
*** 140,145 ****
--- 140,147 ----
  #endif
  #endif
  
+ #include "error.h"
+ 
  #ifndef errno
  extern int errno;
  #endif
*************** extern char *rindex __P((const char *, i
*** 152,158 ****
  #endif
  
  void fatal ();
- void error ();
  void pfatal_with_name ();
  void pfatal_and_delete ();
  char *concat ();
--- 154,159 ----
*************** int mbx_write ();
*** 163,168 ****
--- 164,171 ----
  int mbx_delimit_begin ();
  int mbx_delimit_end ();
  
+ char *program_name = "movemail";
+ 
  /* Nonzero means this is name of a lock file to delete on fatal error.  */
  char *delete_lockname;
  
*************** fatal (s1, s2)
*** 606,630 ****
  {
    if (delete_lockname)
      unlink (delete_lockname);
!   error (s1, s2, 0);
!   exit (EXIT_FAILURE);
! }
! 
! /* Print error message.  `s1' is printf control string, `s2' and `s3'
!    are args for it or null. */
! 
! void
! error (s1, s2, s3)
!      char *s1, *s2, *s3;
! {
!   fprintf (stderr, "movemail: ");
!   if (s3)
!     fprintf (stderr, s1, s2, s3);
!   else if (s2)
!     fprintf (stderr, s1, s2);
!   else
!     fprintf (stderr, s1);
!   fprintf (stderr, "\n");
  }
  
  void
--- 609,615 ----
  {
    if (delete_lockname)
      unlink (delete_lockname);
!   error (EXIT_FAILURE, 0, s1, s2);
  }
  
  void
*************** popmail (mailbox, outfile, preserve, pas
*** 737,749 ****
    server = pop_open (hostname, user, password, POP_NO_GETPASS);
    if (! server)
      {
!       error ("Error connecting to POP server: %s", pop_error, 0);
        return EXIT_FAILURE;
      }
  
    if (pop_stat (server, &nmsgs, &nbytes))
      {
!       error ("Error getting message count from POP server: %s", pop_error, 0);
        return EXIT_FAILURE;
      }
  
--- 722,735 ----
    server = pop_open (hostname, user, password, POP_NO_GETPASS);
    if (! server)
      {
!       error (0, 0, "Error connecting to POP server: %s", pop_error);
        return EXIT_FAILURE;
      }
  
    if (pop_stat (server, &nmsgs, &nbytes))
      {
!       error (0, 0, "Error getting message count from POP server: %s",
!            pop_error);
        return EXIT_FAILURE;
      }
  
*************** popmail (mailbox, outfile, preserve, pas
*** 756,771 ****
    mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666);
    if (mbfi < 0)
      {
        pop_close (server);
!       error ("Error in open: %s, %s", strerror (errno), outfile);
        return EXIT_FAILURE;
      }
    fchown (mbfi, getuid (), -1);
  
    if ((mbf = fdopen (mbfi, "wb")) == NULL)
      {
        pop_close (server);
!       error ("Error in fdopen: %s", strerror (errno), 0);
        close (mbfi);
        unlink (outfile);
        return EXIT_FAILURE;
--- 742,759 ----
    mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666);
    if (mbfi < 0)
      {
+       int e = errno;
        pop_close (server);
!       error (0, e, "Error in open: %s", outfile);
        return EXIT_FAILURE;
      }
    fchown (mbfi, getuid (), -1);
  
    if ((mbf = fdopen (mbfi, "wb")) == NULL)
      {
+       int e = errno;
        pop_close (server);
!       error (0, e, "Error in fdopen");
        close (mbfi);
        unlink (outfile);
        return EXIT_FAILURE;
*************** popmail (mailbox, outfile, preserve, pas
*** 789,795 ****
        mbx_delimit_begin (mbf);
        if (pop_retr (server, i, mbf) != OK)
        {
!         error (Errmsg, 0, 0);
          close (mbfi);
          return EXIT_FAILURE;
        }
--- 777,783 ----
        mbx_delimit_begin (mbf);
        if (pop_retr (server, i, mbf) != OK)
        {
!         error (0, 0, "%s", Errmsg);
          close (mbfi);
          return EXIT_FAILURE;
        }
*************** popmail (mailbox, outfile, preserve, pas
*** 797,803 ****
        fflush (mbf);
        if (ferror (mbf))
        {
!         error ("Error in fflush: %s", strerror (errno), 0);
          pop_close (server);
          close (mbfi);
          return EXIT_FAILURE;
--- 785,791 ----
        fflush (mbf);
        if (ferror (mbf))
        {
!         error (0, errno, "Error in fflush");
          pop_close (server);
          close (mbfi);
          return EXIT_FAILURE;
*************** popmail (mailbox, outfile, preserve, pas
*** 820,826 ****
  
    if (close (mbfi) == -1)
      {
!       error ("Error in close: %s", strerror (errno), 0);
        return EXIT_FAILURE;
      }
  
--- 808,814 ----
  
    if (close (mbfi) == -1)
      {
!       error (0, errno, "Error in close");
        return EXIT_FAILURE;
      }
  
*************** popmail (mailbox, outfile, preserve, pas
*** 829,835 ****
        {
        if (pop_delete (server, i))
          {
!           error ("Error from POP server: %s", pop_error, 0);
            pop_close (server);
            return EXIT_FAILURE;
          }
--- 817,823 ----
        {
        if (pop_delete (server, i))
          {
!           error (0, 0, "Error from POP server: %s", pop_error);
            pop_close (server);
            return EXIT_FAILURE;
          }
*************** popmail (mailbox, outfile, preserve, pas
*** 837,843 ****
  
    if (pop_quit (server))
      {
!       error ("Error from POP server: %s", pop_error, 0);
        return EXIT_FAILURE;
      }
  
--- 825,831 ----
  
    if (pop_quit (server))
      {
!       error (0, 0, "Error from POP server: %s", pop_error);
        return EXIT_FAILURE;
      }
  
Index: lib-src/sorted-doc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/sorted-doc.c,v
retrieving revision 1.14
diff -p -c -r1.14 sorted-doc.c
*** lib-src/sorted-doc.c        8 May 2004 15:23:35 -0000       1.14
--- lib-src/sorted-doc.c        7 Dec 2004 20:56:37 -0000
***************
*** 29,34 ****
--- 29,35 ----
  
  #include <stdio.h>
  #include <ctype.h>
+ #include "error.h"
  #ifndef HAVE_STDLIB_H         /* config.h includes stdlib.  */
  extern char *malloc ();
  #endif
*************** struct docstr                   /* Allocated thing for a
*** 57,72 ****
  };
  
  
! /* Print error message.  `s1' is printf control string, `s2' is arg for it. */
! 
! void
! error (s1, s2)
!      char *s1, *s2;
! {
!   fprintf (stderr, "sorted-doc: ");
!   fprintf (stderr, s1, s2);
!   fprintf (stderr, "\n");
! }
  
  /* Print error message and exit.  */
  
--- 58,64 ----
  };
  
  
! char *program_name = "sorted-doc";
  
  /* Print error message and exit.  */
  
*************** void
*** 74,81 ****
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (s1, s2);
!   exit (EXIT_FAILURE);
  }
  
  /* Like malloc but get fatal error if memory is exhausted.  */
--- 66,72 ----
  fatal (s1, s2)
       char *s1, *s2;
  {
!   error (EXIT_FAILURE, 0, s1, s2);
  }
  
  /* Like malloc but get fatal error if memory is exhausted.  */
*** /dev/null   Tue Mar 18 13:55:57 2003
--- lib-src/error.c     Tue Dec  7 12:14:00 2004
***************
*** 0 ****
--- 1,306 ----
+ /* Error handler for noninteractive utilities
+    Copyright (C) 1990-1998, 2000-2002, 2003, 2004 Free Software Foundation, 
Inc.
+    This file is part of the GNU C Library.
+ 
+    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.  */
+ 
+ /* Written by David MacKenzie <address@hidden>.  */
+ 
+ #ifdef HAVE_CONFIG_H
+ # include <config.h>
+ #endif
+ 
+ #include "error.h"
+ 
+ #include <stdarg.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ #ifdef _LIBC
+ # include <libintl.h>
+ #else
+ # include "gettext.h"
+ #endif
+ 
+ #ifdef _LIBC
+ # include <wchar.h>
+ # define mbsrtowcs __mbsrtowcs
+ #endif
+ 
+ #if USE_UNLOCKED_IO
+ # include "unlocked-io.h"
+ #endif
+ 
+ #ifndef _
+ # define _(String) String
+ #endif
+ 
+ /* If NULL, error will flush stdout, then print on stderr the program
+    name, a colon and a space.  Otherwise, error will call this
+    function without parameters instead.  */
+ void (*error_print_progname) (void);
+ 
+ /* This variable is incremented each time `error' is called.  */
+ unsigned int error_message_count;
+ 
+ #ifdef _LIBC
+ /* In the GNU C library, there is a predefined variable for this.  */
+ 
+ # define program_name program_invocation_name
+ # include <errno.h>
+ # include <libio/libioP.h>
+ 
+ /* In GNU libc we want do not want to use the common name `error' directly.
+    Instead make it a weak alias.  */
+ extern void __error (int status, int errnum, const char *message, ...)
+      __attribute__ ((__format__ (__printf__, 3, 4)));
+ extern void __error_at_line (int status, int errnum, const char *file_name,
+                            unsigned int line_number, const char *message,
+                            ...)
+      __attribute__ ((__format__ (__printf__, 5, 6)));;
+ # define error __error
+ # define error_at_line __error_at_line
+ 
+ # include <libio/iolibio.h>
+ # define fflush(s) INTUSE(_IO_fflush) (s)
+ # undef putc
+ # define putc(c, fp) INTUSE(_IO_putc) (c, fp)
+ 
+ # include <bits/libc-lock.h>
+ 
+ #else /* not _LIBC */
+ 
+ # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
+ #  ifndef HAVE_DECL_STRERROR_R
+ "this configure-time declaration test was not run"
+ #  endif
+ char *strerror_r ();
+ # endif
+ 
+ # ifndef SIZE_MAX
+ #  define SIZE_MAX ((size_t) -1)
+ # endif
+ 
+ /* The calling program should define program_name and set it to the
+    name of the executing program.  */
+ extern char *program_name;
+ 
+ # if HAVE_STRERROR_R || defined strerror_r
+ #  define __strerror_r strerror_r
+ # endif
+ #endif        /* not _LIBC */
+ 
+ static void
+ print_errno_message (int errnum)
+ {
+   char const *s = NULL;
+ 
+ #if defined HAVE_STRERROR_R || _LIBC
+   char errbuf[1024];
+ # if STRERROR_R_CHAR_P || _LIBC
+   s = __strerror_r (errnum, errbuf, sizeof errbuf);
+ # else
+   if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
+     s = errbuf;
+ # endif
+ #endif
+ 
+ #if !_LIBC
+   if (! s && ! (s = strerror (errnum)))
+     s = _("Unknown system error");
+ #endif
+ 
+ #if _LIBC
+   if (_IO_fwide (stderr, 0) > 0)
+     {
+       __fwprintf (stderr, L": %s", s);
+       return;
+     }
+ #endif
+ 
+   fprintf (stderr, ": %s", s);
+ }
+ 
+ static void
+ error_tail (int status, int errnum, const char *message, va_list args)
+ {
+ #if _LIBC
+   if (_IO_fwide (stderr, 0) > 0)
+     {
+ # define ALLOCA_LIMIT 2000
+       size_t len = strlen (message) + 1;
+       const wchar_t *wmessage = L"out of memory";
+       wchar_t *wbuf = (len < ALLOCA_LIMIT
+                      ? alloca (len * sizeof *wbuf)
+                      : len <= SIZE_MAX / sizeof *wbuf
+                      ? malloc (len * sizeof *wbuf)
+                      : NULL);
+ 
+       if (wbuf)
+       {
+         size_t res;
+         mbstate_t st;
+         const char *tmp = message;
+         memset (&st, '\0', sizeof (st));
+         res = mbsrtowcs (wbuf, &tmp, len, &st);
+         wmessage = res == (size_t) -1 ? L"???" : wbuf;
+       }
+ 
+       __vfwprintf (stderr, wmessage, args);
+       if (! (len < ALLOCA_LIMIT))
+       free (wbuf);
+     }
+   else
+ #endif
+     vfprintf (stderr, message, args);
+   va_end (args);
+ 
+   ++error_message_count;
+   if (errnum)
+     print_errno_message (errnum);
+ #if _LIBC
+   if (_IO_fwide (stderr, 0) > 0)
+     putwc (L'\n', stderr);
+   else
+ #endif
+     putc ('\n', stderr);
+   fflush (stderr);
+   if (status)
+     exit (status);
+ }
+ 
+ 
+ /* Print the program name and error message MESSAGE, which is a printf-style
+    format string with optional args.
+    If ERRNUM is nonzero, print its corresponding system error message.
+    Exit with status STATUS if it is nonzero.  */
+ void
+ error (int status, int errnum, const char *message, ...)
+ {
+   va_list args;
+ 
+ #if defined _LIBC && defined __libc_ptf_call
+   /* We do not want this call to be cut short by a thread
+      cancellation.  Therefore disable cancellation for now.  */
+   int state = PTHREAD_CANCEL_ENABLE;
+   __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+                  0);
+ #endif
+ 
+   fflush (stdout);
+ #ifdef _LIBC
+   _IO_flockfile (stderr);
+ #endif
+   if (error_print_progname)
+     (*error_print_progname) ();
+   else
+     {
+ #if _LIBC
+       if (_IO_fwide (stderr, 0) > 0)
+       __fwprintf (stderr, L"%s: ", program_name);
+       else
+ #endif
+       fprintf (stderr, "%s: ", program_name);
+     }
+ 
+   va_start (args, message);
+   error_tail (status, errnum, message, args);
+ 
+ #ifdef _LIBC
+   _IO_funlockfile (stderr);
+ # ifdef __libc_ptf_call
+   __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+ # endif
+ #endif
+ }
+ 
+ /* Sometimes we want to have at most one error per line.  This
+    variable controls whether this mode is selected or not.  */
+ int error_one_per_line;
+ 
+ void
+ error_at_line (int status, int errnum, const char *file_name,
+              unsigned int line_number, const char *message, ...)
+ {
+   va_list args;
+ 
+   if (error_one_per_line)
+     {
+       static const char *old_file_name;
+       static unsigned int old_line_number;
+ 
+       if (old_line_number == line_number
+         && (file_name == old_file_name
+             || strcmp (old_file_name, file_name) == 0))
+       /* Simply return and print nothing.  */
+       return;
+ 
+       old_file_name = file_name;
+       old_line_number = line_number;
+     }
+ 
+ #if defined _LIBC && defined __libc_ptf_call
+   /* We do not want this call to be cut short by a thread
+      cancellation.  Therefore disable cancellation for now.  */
+   int state = PTHREAD_CANCEL_ENABLE;
+   __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+                  0);
+ #endif
+ 
+   fflush (stdout);
+ #ifdef _LIBC
+   _IO_flockfile (stderr);
+ #endif
+   if (error_print_progname)
+     (*error_print_progname) ();
+   else
+     {
+ #if _LIBC
+       if (_IO_fwide (stderr, 0) > 0)
+       __fwprintf (stderr, L"%s: ", program_name);
+       else
+ #endif
+       fprintf (stderr, "%s:", program_name);
+     }
+ 
+   if (file_name != NULL)
+     {
+ #if _LIBC
+       if (_IO_fwide (stderr, 0) > 0)
+       __fwprintf (stderr, L"%s:%d: ", file_name, line_number);
+       else
+ #endif
+       fprintf (stderr, "%s:%d: ", file_name, line_number);
+     }
+ 
+   va_start (args, message);
+   error_tail (status, errnum, message, args);
+ 
+ #ifdef _LIBC
+   _IO_funlockfile (stderr);
+ # ifdef __libc_ptf_call
+   __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+ # endif
+ #endif
+ }
+ 
+ #ifdef _LIBC
+ /* Make the weak alias.  */
+ # undef error
+ # undef error_at_line
+ weak_alias (__error, error)
+ weak_alias (__error_at_line, error_at_line)
+ #endif
*** /dev/null   Tue Mar 18 13:55:57 2003
--- lib-src/error.h     Tue Dec  7 12:14:00 2004
***************
*** 0 ****
--- 1,66 ----
+ /* Declaration for error-reporting function
+    Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+ 
+    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 _ERROR_H
+ #define _ERROR_H 1
+ 
+ #ifndef __attribute__
+ /* This feature is available in gcc versions 2.5 and later.  */
+ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+ #  define __attribute__(Spec) /* empty */
+ # endif
+ /* The __-protected variants of `format' and `printf' attributes
+    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+ #  define __format__ format
+ #  define __printf__ printf
+ # endif
+ #endif
+ 
+ #ifdef        __cplusplus
+ extern "C" {
+ #endif
+ 
+ /* Print a message with `fprintf (stderr, FORMAT, ...)';
+    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
+    If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
+ 
+ extern void error (int __status, int __errnum, const char *__format, ...)
+      __attribute__ ((__format__ (__printf__, 3, 4)));
+ 
+ extern void error_at_line (int __status, int __errnum, const char *__fname,
+                          unsigned int __lineno, const char *__format, ...)
+      __attribute__ ((__format__ (__printf__, 5, 6)));
+ 
+ /* If NULL, error will flush stdout, then print on stderr the program
+    name, a colon and a space.  Otherwise, error will call this
+    function without parameters instead.  */
+ extern void (*error_print_progname) (void);
+ 
+ /* This variable is incremented each time `error' is called.  */
+ extern unsigned int error_message_count;
+ 
+ /* Sometimes we want to have at most one error per line.  This
+    variable controls whether this mode is selected or not.  */
+ extern int error_one_per_line;
+ 
+ #ifdef        __cplusplus
+ }
+ #endif
+ 
+ #endif /* error.h */
*** /dev/null   Tue Mar 18 13:55:57 2003
--- lib-src/gettext.h   Tue Dec  7 12:14:09 2004
***************
*** 0 ****
--- 1,68 ----
+ /* Convenience header for conditional use of GNU <libintl.h>.
+    Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
+ 
+    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 _LIBGETTEXT_H
+ #define _LIBGETTEXT_H 1
+ 
+ /* NLS can be disabled through the configure --disable-nls option.  */
+ #if ENABLE_NLS
+ 
+ /* Get declarations of GNU message catalog functions.  */
+ # include <libintl.h>
+ 
+ #else
+ 
+ /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+    chokes if dcgettext is defined as a macro.  So include it now, to make
+    later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
+    as well because people using "gettext.h" will not include <libintl.h>,
+    and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+    is OK.  */
+ #if defined(__sun)
+ # include <locale.h>
+ #endif
+ 
+ /* Disabled NLS.
+    The casts to 'const char *' serve the purpose of producing warnings
+    for invalid uses of the value returned from these functions.
+    On pre-ANSI systems without 'const', the config.h file is supposed to
+    contain "#define const".  */
+ # define gettext(Msgid) ((const char *) (Msgid))
+ # define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+ # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+ # define ngettext(Msgid1, Msgid2, N) \
+     ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+ # define dngettext(Domainname, Msgid1, Msgid2, N) \
+     ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+ # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+     ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+ # define textdomain(Domainname) ((const char *) (Domainname))
+ # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+ # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) 
(Codeset))
+ 
+ #endif
+ 
+ /* A pseudo function call that serves as a marker for the automated
+    extraction of messages, but does not call gettext().  The run-time
+    translation is done at a different place in the code.
+    The argument, String, should be a literal string.  Concatenated strings
+    and other string expressions won't work.
+    The macro's expansion is not parenthesized, so that it is suitable as
+    initializer for static 'char[]' or 'const char[]' variables.  */
+ #define gettext_noop(String) String
+ 
+ #endif /* _LIBGETTEXT_H */




reply via email to

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