]>
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>. */
25 #if ! (HAVE_VPRINTF || defined vfprintf)
26 # define vfprintf(stream, message, args) _doprnt (message, args, stream)
29 #if STDC_HEADERS || _LIBC
39 # define _(String) String
43 /* In the GNU C library, there is a predefined variable for this. */
45 # define program_name program_invocation_name
48 /* In GNU libc we want do not want to use the common name `error' directly.
49 Instead make it a weak alias. */
50 # define error __error
51 # define error_at_line __error_at_line
54 # include <libio/iolibio.h>
55 # define fflush(s) _IO_fflush (s)
60 /* The calling program should define program_name and set it to the
61 name of the executing program. */
62 extern char *program_name
;
65 # ifndef HAVE_DECL_STRERROR
66 "this configure-time declaration test was not run"
68 # if !HAVE_DECL_STRERROR && !defined strerror
73 private_strerror (int errnum
)
75 extern char *sys_errlist
[];
78 if (errnum
> 0 && errnum
<= sys_nerr
)
79 return _(sys_errlist
[errnum
]);
80 return _("Unknown system error");
82 # define strerror private_strerror
83 # endif /* HAVE_STRERROR */
84 #endif /* not _LIBC */
86 /* This variable is incremented each time `warn' is called. */
87 unsigned int warn_message_count
;
89 /* This variable is incremented each time `complain' is called. */
90 unsigned int complain_message_count
;
93 /*--------------------------------.
94 | Report a warning, and proceed. |
95 `--------------------------------*/
98 warn_at (location_t location
, const char *message
, ...)
103 LOCATION_PRINT (stderr
, location
);
104 fputs (": ", stderr
);
105 fputs (_("warning: "), stderr
);
107 va_start (args
, message
);
108 vfprintf (stderr
, message
, args
);
111 ++warn_message_count
;
117 warn (const char *message
, ...)
122 fprintf (stderr
, "%s: %s", infile
? infile
: program_name
, _("warning: "));
124 va_start (args
, message
);
125 vfprintf (stderr
, message
, args
);
128 ++warn_message_count
;
133 /*-----------------------------------------------------------.
134 | An error has occurred, but we can proceed, and die later. |
135 `-----------------------------------------------------------*/
138 complain_at (location_t location
, const char *message
, ...)
143 LOCATION_PRINT (stderr
, location
);
144 fputs (": ", stderr
);
146 va_start (args
, message
);
147 vfprintf (stderr
, message
, args
);
150 ++complain_message_count
;
156 complain (const char *message
, ...)
161 fprintf (stderr
, "%s: ", infile
? infile
: program_name
);
163 va_start (args
, message
);
164 vfprintf (stderr
, message
, args
);
167 ++complain_message_count
;
172 /*-------------------------------------------------.
173 | A severe error has occurred, we cannot proceed. |
174 `-------------------------------------------------*/
177 fatal_at (location_t location
, const char *message
, ...)
182 LOCATION_PRINT (stderr
, location
);
183 fputs (": ", stderr
);
184 fputs (_("fatal error: "), stderr
);
186 va_start (args
, message
);
187 vfprintf (stderr
, message
, args
);
195 fatal (const char *message
, ...)
200 fprintf (stderr
, "%s: ", infile
? infile
: program_name
);
202 fputs (_("fatal error: "), stderr
);
204 va_start (args
, message
);
205 vfprintf (stderr
, message
, args
);