Mercurial > hg > octave-kai > gnulib-hg
annotate lib/fatal.c @ 4739:04758f7475fd
Merge changes from glibc.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 26 Sep 2003 07:35:01 +0000 |
parents | 4753d416bf20 |
children |
rev | line source |
---|---|
4333 | 1 /* Fatal exits for noninteractive utilities |
2 | |
3 Copyright (C) 2001, 2003 Free Software Foundation, Inc. | |
4 | |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License along | |
16 with this program; if not, write to the Free Software Foundation, | |
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
18 | |
2449 | 19 #ifdef HAVE_CONFIG_H |
20 # include <config.h> | |
21 #endif | |
22 | |
4642 | 23 #include "fatal.h" |
2449 | 24 |
4696
4753d416bf20
Use "exit.h" rather than rolling EXIT_FAILURE ourselves in each module.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4642
diff
changeset
|
25 #include "exit.h" |
4642 | 26 #include <stdarg.h> |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
2449 | 30 |
31 #ifdef _LIBC | |
32 # define program_name program_invocation_name | |
33 #else /* not _LIBC */ | |
34 /* The calling program should define program_name and set it to the | |
35 name of the executing program. */ | |
36 extern char *program_name; | |
37 #endif | |
38 | |
3618 | 39 #include "unlocked-io.h" |
2449 | 40 |
41 /* Like error, but always exit with EXIT_FAILURE. */ | |
42 | |
43 void | |
44 fatal (int errnum, const char *message, ...) | |
45 { | |
46 va_list args; | |
47 | |
48 if (error_print_progname) | |
49 (*error_print_progname) (); | |
50 else | |
51 { | |
52 fflush (stdout); | |
53 fprintf (stderr, "%s: ", program_name); | |
54 } | |
55 | |
4642 | 56 va_start (args, message); |
2449 | 57 error (EXIT_FAILURE, errnum, message, args); |
4642 | 58 |
59 /* The following code isn't reachable, but pacifies some compilers. */ | |
2449 | 60 va_end (args); |
4642 | 61 abort (); |
2449 | 62 } |