Add err.[ch] to portability checks (as yet unused).
authorjbj <devnull@localhost>
Mon, 20 Sep 1999 15:35:08 +0000 (15:35 +0000)
committerjbj <devnull@localhost>
Mon, 20 Sep 1999 15:35:08 +0000 (15:35 +0000)
get latest error.[ch] from glibc.

CVS patchset: 3310
CVS date: 1999/09/20 15:35:08

configure.in
misc/Makefile.am
misc/err.c [new file with mode: 0644]
misc/err.h [new file with mode: 0644]
misc/error.c
misc/error.h

index 5c21f75..664f4e1 100644 (file)
@@ -586,6 +586,7 @@ dnl XXX AC_CHECK_FUNCS(gethostname mkdir mkfifo rmdir select uname)
 
 AC_CHECK_FUNCS(mtrace)
 
+AC_REPLACE_FUNCS(err getcwd getwd glob inet_aton putenv realpath)
 AC_REPLACE_FUNCS(getcwd getwd glob inet_aton putenv realpath)
 AC_REPLACE_FUNCS(strdup strerror strtol strtoul strspn strstr)
 
index 38f9155..d838b7e 100644 (file)
@@ -5,16 +5,16 @@ AUTOMAKE_OPTIONS = 1.4 foreign
 INCLUDES = -I$(top_srcdir) @INCPATH@
 
 EXTRA_DIST = \
-       alloca.c        basename.c      error.c         fakefork.c      \
-       fnmatch.c       getcwd.c        getmntent.c     getwd.c         \
-       glob.c          inet_aton.c     memcmp.c        mktime.c        \
-       myrealloc.c     putenv.c        realpath.c      stpcpy.c        \
-       stpncpy.c       strcasecmp.c    strncasecmp.c   strcspn.c       \
-       strdup.c        strerror.c      strftime.c      strcspn.c       \
-       strstr.c        strtol.c        strtoul.c
+       alloca.c        basename.c      err.c           error.c         \
+       fakefork.c      fnmatch.c       getcwd.c        getmntent.c     \
+       getwd.c         glob.c          inet_aton.c     memcmp.c        \
+       mktime.c        myrealloc.c     putenv.c        realpath.c      \
+       stpcpy.c        stpncpy.c       strcasecmp.c    strncasecmp.c   \
+       strcspn.c       strdup.c        strerror.c      strftime.c      \
+       strcspn.c       strstr.c        strtol.c        strtoul.c
 
 noinst_HEADERS = \
-       error.h         fnmatch.h       glob.h                          \
+       err.h           error.h         fnmatch.h       glob.h          \
        libgettext.h    message.h       po-lex.h        str-list.h      \
        fstrcmp.h
 
diff --git a/misc/err.c b/misc/err.c
new file mode 100644 (file)
index 0000000..3482944
--- /dev/null
@@ -0,0 +1,109 @@
+/* err.c --- 4.4BSD utility functions for error messages.
+   Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <stdarg.h>
+#include <err.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
+extern char *__progname;
+
+#define VA(call)                                                             \
+{                                                                            \
+  va_list ap;                                                                \
+  va_start (ap, format);                                                     \
+  call;                                                                              \
+  va_end (ap);                                                               \
+}
+
+void
+vwarnx (const char *format, __gnuc_va_list ap)
+{
+  flockfile (stderr);
+  if (__progname)
+    fprintf (stderr, "%s: ", __progname);
+  if (format)
+    vfprintf (stderr, format, ap);
+  putc_unlocked ('\n', stderr);
+  funlockfile (stderr);
+}
+
+void
+vwarn (const char *format, __gnuc_va_list ap)
+{
+  int error = errno;
+
+  flockfile (stderr);
+  if (__progname)
+    fprintf (stderr, "%s: ", __progname);
+  if (format)
+    {
+      vfprintf (stderr, format, ap);
+      fputs_unlocked (": ", stderr);
+    }
+  __set_errno (error);
+  fprintf (stderr, "%m\n");
+  funlockfile (stderr);
+}
+
+
+void
+warn (const char *format, ...)
+{
+  VA (vwarn (format, ap))
+}
+
+void
+warnx (const char *format, ...)
+{
+  VA (vwarnx (format, ap))
+}
+
+void
+verr (int status, const char *format, __gnuc_va_list ap)
+{
+  vwarn (format, ap);
+  exit (status);
+}
+
+void
+verrx (int status, const char *format, __gnuc_va_list ap)
+{
+  vwarnx (format, ap);
+  exit (status);
+}
+
+void
+err (int status, const char *format, ...)
+{
+  VA (verr (status, format, ap))
+}
+
+void
+errx (int status, const char *format, ...)
+{
+  VA (verrx (status, format, ap))
+}
diff --git a/misc/err.h b/misc/err.h
new file mode 100644 (file)
index 0000000..6170006
--- /dev/null
@@ -0,0 +1,58 @@
+/* 4.4BSD utility functions for error messages.
+   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef        _ERR_H
+#define        _ERR_H  1
+
+#include <features.h>
+
+#define        __need___va_list
+#include <stdarg.h>
+#ifndef        __GNUC_VA_LIST
+# define __gnuc_va_list        __ptr_t
+#endif
+
+__BEGIN_DECLS
+
+/* Print "program: ", FORMAT, ": ", the standard error string for errno,
+   and a newline, on stderr.  */
+extern void warn __P ((__const char *__format, ...))
+     __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void vwarn __P ((__const char *__format, __gnuc_va_list))
+     __attribute__ ((__format__ (__printf__, 1, 0)));
+
+/* Likewise, but without ": " and the standard error string.  */
+extern void warnx __P ((__const char *__format, ...))
+     __attribute__ ((__format__ (__printf__, 1, 2)));
+extern void vwarnx __P ((__const char *__format, __gnuc_va_list))
+     __attribute__ ((__format__ (__printf__, 1, 0)));
+
+/* Likewise, and then exit with STATUS.  */
+extern void err __P ((int __status, __const char *__format, ...))
+     __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
+extern void verr __P ((int __status, __const char *__format, __gnuc_va_list))
+     __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
+extern void errx __P ((int __status, __const char *__format, ...))
+     __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
+extern void verrx __P ((int __status, __const char *, __gnuc_va_list))
+     __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
+
+__END_DECLS
+
+#endif /* err.h */
index 140fa77..ca7f3b4 100644 (file)
@@ -1,24 +1,23 @@
 /* Error handler for noninteractive utilities
    Copyright (C) 1990,91,92,93,94,95,96,97,98 Free Software Foundation, Inc.
 
+   This file is part of the GNU C Library.  Its master source is NOT part of
+   the C library, however.  The master source lives in /gd/gnu/lib.
 
-   NOTE: The canonical source of this file is maintained with the GNU C Library.
-   Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-   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,
+   The GNU C Library 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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
 
@@ -77,6 +76,11 @@ unsigned int error_message_count;
 # define error __error
 # define error_at_line __error_at_line
 
+# ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+#  define fflush(s) _IO_fflush (s)
+# endif
+
 #else /* not _LIBC */
 
 /* The calling program should define program_name and set it to the
index 20f7582..0d3bcb7 100644 (file)
@@ -1,24 +1,23 @@
 /* Declaration for error-reporting function
    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
 
+   This file is part of the GNU C Library.  Its master source is NOT part of
+   the C library, however.  The master source lives in /gd/gnu/lib.
 
-   NOTE: The canonical source of this file is maintained with the GNU C Library.
-   Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-   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,
+   The GNU C Library 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.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library 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.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  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