]>
git.saurik.com Git - bison.git/blob - src/complain.c
14ef2388c9aea33eeeff7f789c9a5bdf1e9b5dd5
1 /* Declaration for error-reporting function for Bison.
2 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any
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.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 /* Based on error.c and error.h,
20 written by David MacKenzie <djm@gnu.ai.mit.edu>. */
24 #if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
27 # define VA_START(args, lastarg) va_start(args, lastarg)
30 # define VA_START(args, lastarg) va_start(args)
33 # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
34 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
37 #if STDC_HEADERS || _LIBC
46 #ifndef HAVE_DECL_STRERROR_R
47 "this configure-time declaration test was not run"
49 #if !HAVE_DECL_STRERROR_R
54 # define _(String) String
58 /* In the GNU C library, there is a predefined variable for this. */
60 # define program_name program_invocation_name
63 /* In GNU libc we want do not want to use the common name `error' directly.
64 Instead make it a weak alias. */
65 # define error __error
66 # define error_at_line __error_at_line
69 # include <libio/iolibio.h>
70 # define fflush(s) _IO_fflush (s)
75 /* The calling program should define program_name and set it to the
76 name of the executing program. */
77 extern char *program_name
;
79 # ifdef HAVE_STRERROR_R
80 # define __strerror_r strerror_r
83 # ifndef strerror /* On some systems, strerror is a macro */
88 private_strerror (errnum
)
91 extern char *sys_errlist
[];
94 if (errnum
> 0 && errnum
<= sys_nerr
)
95 return _(sys_errlist
[errnum
]);
96 return _("Unknown system error");
98 # define strerror private_strerror
99 # endif /* HAVE_STRERROR */
100 # endif /* HAVE_STRERROR_R */
101 #endif /* not _LIBC */
103 /* This variable is incremented each time `warn' is called. */
104 unsigned int warn_message_count
;
106 /* This variable is incremented each time `complain' is called. */
107 unsigned int complain_message_count
;
110 /*--------------------------------.
111 | Report a warning, and proceed. |
112 `--------------------------------*/
115 #if defined VA_START && defined __STDC__
116 warn_at (location_t location
, const char *message
, ...)
118 warn_at (location
, message
, va_alist
)
129 LOCATION_PRINT (stderr
, location
);
130 fputs (": ", stderr
);
131 fputs (_("warning: "), stderr
);
134 VA_START (args
, message
);
135 vfprintf (stderr
, message
, args
);
138 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
141 ++warn_message_count
;
147 #if defined VA_START && defined __STDC__
148 warn (const char *message
, ...)
150 warn (message
, va_alist
)
160 fprintf (stderr
, "%s: %s", infile
? infile
: program_name
, _("warning: "));
163 VA_START (args
, message
);
164 vfprintf (stderr
, message
, args
);
167 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
170 ++warn_message_count
;
175 /*-----------------------------------------------------------.
176 | An error has occurred, but we can proceed, and die later. |
177 `-----------------------------------------------------------*/
180 #if defined VA_START && defined __STDC__
181 complain_at (location_t location
, const char *message
, ...)
183 complain_at (location
, message
, va_alist
)
194 LOCATION_PRINT (stderr
, location
);
195 fputs (": ", stderr
);
198 VA_START (args
, message
);
199 vfprintf (stderr
, message
, args
);
202 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
205 ++complain_message_count
;
211 #if defined VA_START && defined __STDC__
212 complain (const char *message
, ...)
214 complain (message
, va_alist
)
224 fprintf (stderr
, "%s: ", infile
? infile
: program_name
);
227 VA_START (args
, message
);
228 vfprintf (stderr
, message
, args
);
231 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
234 ++complain_message_count
;
239 /*-------------------------------------------------.
240 | A severe error has occurred, we cannot proceed. |
241 `-------------------------------------------------*/
244 #if defined VA_START && defined __STDC__
245 fatal_at (location_t location
, const char *message
, ...)
247 fatal_at (location
, message
, va_alist
)
258 LOCATION_PRINT (stderr
, location
);
259 fputs (": ", stderr
);
260 fputs (_("fatal error: "), stderr
);
263 VA_START (args
, message
);
264 vfprintf (stderr
, message
, args
);
267 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
275 #if defined VA_START && defined __STDC__
276 fatal (const char *message
, ...)
278 fatal (message
, va_alist
)
288 fprintf (stderr
, "%s: ", infile
? infile
: program_name
);
290 fputs (_("fatal error: "), stderr
);
293 VA_START (args
, message
);
294 vfprintf (stderr
, message
, args
);
297 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);