(ISSLASH): Define.
[gnulib.git] / lib / fatal.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <stdio.h>
6
7 #if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
8 # if __STDC__
9 #  include <stdarg.h>
10 #  define VA_START(args, lastarg) va_start(args, lastarg)
11 # else
12 #  include <varargs.h>
13 #  define VA_START(args, lastarg) va_start(args)
14 # endif
15 #else
16 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
17 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
18 #endif
19
20 #if STDC_HEADERS || _LIBC
21 # include <stdlib.h>
22 # include <string.h>
23 #else
24 void exit ();
25 #endif
26
27 #ifdef _LIBC
28 # define program_name program_invocation_name
29 #else /* not _LIBC */
30 /* The calling program should define program_name and set it to the
31    name of the executing program.  */
32 extern char *program_name;
33 #endif
34
35 #include "fatal.h"
36
37 /* Like error, but always exit with EXIT_FAILURE.  */
38
39 void
40 #if defined VA_START && __STDC__
41 fatal (int errnum, const char *message, ...)
42 #else
43 fatal (errnum, message, va_alist)
44      int errnum;
45      char *message;
46      va_dcl
47 #endif
48 {
49 #ifdef VA_START
50   va_list args;
51 #endif
52
53   if (error_print_progname)
54     (*error_print_progname) ();
55   else
56     {
57       fflush (stdout);
58       fprintf (stderr, "%s: ", program_name);
59     }
60
61 #ifdef VA_START
62   VA_START (args, message);
63   error (EXIT_FAILURE, errnum, message, args);
64   va_end (args);
65 #else
66   error (EXIT_FAILURE, errnum, message, a1, a2, a3, a4, a5, a6, a7, a8);
67 #endif
68 }