Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/verror.c @ 7292:17785d5bede0
Fix docstrings
author | Sergey Poznyakoff <gray@gnu.org.ua> |
---|---|
date | Sun, 10 Sep 2006 11:52:44 +0000 |
parents | c645fbe36091 |
children | 8e5e6419e8f9 |
rev | line source |
---|---|
7092 | 1 /* va_list error handler for noninteractive utilities |
2 Copyright (C) 2006 Free Software Foundation, Inc. | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License along | |
15 with this program; if not, write to the Free Software Foundation, | |
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
17 | |
18 /* Written by Eric Blake. */ | |
19 | |
20 #ifdef HAVE_CONFIG_H | |
21 # include <config.h> | |
22 #endif | |
23 | |
24 #include "verror.h" | |
25 #include "xvasprintf.h" | |
26 | |
27 #include <errno.h> | |
28 #include <stdarg.h> | |
29 #include <stdlib.h> | |
30 | |
31 #if ENABLE_NLS | |
32 # include "gettext.h" | |
33 #endif | |
34 | |
35 #ifndef _ | |
36 # define _(String) String | |
37 #endif | |
38 | |
39 /* Print a message with `vfprintf (stderr, FORMAT, ARGS)'; | |
40 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). | |
41 If STATUS is nonzero, terminate the program with `exit (STATUS)'. | |
42 Use the globals error_print_progname and error_message_count similarly | |
43 to error(). */ | |
44 void | |
45 verror (int status, int errnum, const char *format, va_list args) | |
46 { | |
47 verror_at_line (status, errnum, NULL, 0, format, args); | |
48 } | |
49 | |
50 /* Print a message with `vfprintf (stderr, FORMAT, ARGS)'; | |
51 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). | |
52 If STATUS is nonzero, terminate the program with `exit (STATUS)'. | |
53 If FNAME is not NULL, prepend the message with `FNAME:LINENO:'. | |
54 Use the globals error_print_progname, error_message_count, and | |
55 error_one_per_line similarly to error_at_line(). */ | |
56 void | |
57 verror_at_line (int status, int errnum, const char *file, | |
58 unsigned int line_number, const char *format, va_list args) | |
59 { | |
60 char *message = xvasprintf (format, args); | |
61 if (message) | |
7095
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
62 { |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
63 /* Until http://sourceware.org/bugzilla/show_bug.cgi?id=2997 is fixed, |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
64 glibc violates GNU Coding Standards when the file argument to |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
65 error_at_line is NULL. */ |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
66 if (file) |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
67 error_at_line (status, errnum, file, line_number, "%s", message); |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
68 else |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
69 error (status, errnum, "%s", message); |
c645fbe36091
* verror.c (verror_at_line): Work around glibc bug 2997, so that
Eric Blake <ebb9@byu.net>
parents:
7092
diff
changeset
|
70 } |
7092 | 71 else |
72 { | |
73 /* EOVERFLOW, EINVAL, and EILSEQ from xvasprintf are signs of | |
74 serious programmer errors. */ | |
75 error (0, errno, _("unable to display error message")); | |
76 abort (); | |
77 } | |
78 free (message); | |
79 } |