From 862d856cf0083d07c86d56dce8f9be7b207a8dd4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 30 Apr 2000 16:24:00 +0000 Subject: [PATCH] . --- lib/error.h | 2 +- lib/fatal.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 lib/fatal.c diff --git a/lib/error.h b/lib/error.h index 20f75824d6..1f68171807 100644 --- a/lib/error.h +++ b/lib/error.h @@ -1,5 +1,5 @@ /* Declaration for error-reporting function - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. diff --git a/lib/fatal.c b/lib/fatal.c new file mode 100644 index 0000000000..b5c8b57fa4 --- /dev/null +++ b/lib/fatal.c @@ -0,0 +1,70 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +/* FIXME: define EXIT_FAILURE */ + +#include + +#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC +# if __STDC__ +# include +# define VA_START(args, lastarg) va_start(args, lastarg) +# else +# include +# define VA_START(args, lastarg) va_start(args) +# endif +#else +# define va_alist a1, a2, a3, a4, a5, a6, a7, a8 +# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; +#endif + +#if STDC_HEADERS || _LIBC +# include +# include +#else +void exit (); +#endif + +#ifdef _LIBC +# define program_name program_invocation_name +#else /* not _LIBC */ +/* The calling program should define program_name and set it to the + name of the executing program. */ +extern char *program_name; +#endif + +#include "fatal.h" + +/* Like error, but always exit with EXIT_FAILURE. */ + +void +#if defined VA_START && __STDC__ +fatal (int errnum, const char *message, ...) +#else +fatal (errnum, message, va_alist) + int errnum; + char *message; + va_dcl +#endif +{ +#ifdef VA_START + va_list args; +#endif + + if (error_print_progname) + (*error_print_progname) (); + else + { + fflush (stdout); + fprintf (stderr, "%s: ", program_name); + } + +#ifdef VA_START + VA_START (args, message); + error (EXIT_FAILURE, errnum, message, args); + va_end (args); +#else + error (EXIT_FAILURE, errnum, message, a1, a2, a3, a4, a5, a6, a7, a8); +#endif +} -- 2.30.2