]>
git.saurik.com Git - bison.git/blob - src/complain.c
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
47 # define _(String) String
51 /* In the GNU C library, there is a predefined variable for this. */
53 # define program_name program_invocation_name
56 /* In GNU libc we want do not want to use the common name `error' directly.
57 Instead make it a weak alias. */
58 # define error __error
59 # define error_at_line __error_at_line
62 # include <libio/iolibio.h>
63 # define fflush(s) _IO_fflush (s)
68 /* The calling program should define program_name and set it to the
69 name of the executing program. */
70 extern char *program_name
;
73 # ifndef HAVE_DECL_STRERROR
74 "this configure-time declaration test was not run"
76 # if !HAVE_DECL_STRERROR && !defined strerror
77 char *strerror
PARAMS ((int));
81 private_strerror (errnum
)
84 extern char *sys_errlist
[];
87 if (errnum
> 0 && errnum
<= sys_nerr
)
88 return _(sys_errlist
[errnum
]);
89 return _("Unknown system error");
91 # define strerror private_strerror
92 # endif /* HAVE_STRERROR */
93 #endif /* not _LIBC */
95 /* This variable is incremented each time `warn' is called. */
96 unsigned int warn_message_count
;
98 /* This variable is incremented each time `complain' is called. */
99 unsigned int complain_message_count
;
102 /*--------------------------------.
103 | Report a warning, and proceed. |
104 `--------------------------------*/
107 #if defined VA_START && defined __STDC__
108 warn_at (location_t location
, const char *message
, ...)
110 warn_at (location
, message
, va_alist
)
121 LOCATION_PRINT (stderr
, location
);
122 fputs (": ", stderr
);
123 fputs (_("warning: "), stderr
);
126 VA_START (args
, message
);
127 vfprintf (stderr
, message
, args
);
130 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
133 ++warn_message_count
;
139 #if defined VA_START && defined __STDC__
140 warn (const char *message
, ...)
142 warn (message
, va_alist
)
152 fprintf (stderr
, "%s: %s", infile
? infile
: program_name
, _("warning: "));
155 VA_START (args
, message
);
156 vfprintf (stderr
, message
, args
);
159 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
162 ++warn_message_count
;
167 /*-----------------------------------------------------------.
168 | An error has occurred, but we can proceed, and die later. |
169 `-----------------------------------------------------------*/
172 #if defined VA_START && defined __STDC__
173 complain_at (location_t location
, const char *message
, ...)
175 complain_at (location
, message
, va_alist
)
186 LOCATION_PRINT (stderr
, location
);
187 fputs (": ", stderr
);
190 VA_START (args
, message
);
191 vfprintf (stderr
, message
, args
);
194 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
197 ++complain_message_count
;
203 #if defined VA_START && defined __STDC__
204 complain (const char *message
, ...)
206 complain (message
, va_alist
)
216 fprintf (stderr
, "%s: ", infile
? infile
: program_name
);
219 VA_START (args
, message
);
220 vfprintf (stderr
, message
, args
);
223 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
226 ++complain_message_count
;
231 /*-------------------------------------------------.
232 | A severe error has occurred, we cannot proceed. |
233 `-------------------------------------------------*/
236 #if defined VA_START && defined __STDC__
237 fatal_at (location_t location
, const char *message
, ...)
239 fatal_at (location
, message
, va_alist
)
250 LOCATION_PRINT (stderr
, location
);
251 fputs (": ", stderr
);
252 fputs (_("fatal error: "), stderr
);
255 VA_START (args
, message
);
256 vfprintf (stderr
, message
, args
);
259 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);
267 #if defined VA_START && defined __STDC__
268 fatal (const char *message
, ...)
270 fatal (message
, va_alist
)
280 fprintf (stderr
, "%s: ", infile
? infile
: program_name
);
282 fputs (_("fatal error: "), stderr
);
285 VA_START (args
, message
);
286 vfprintf (stderr
, message
, args
);
289 fprintf (stderr
, message
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
);