]>
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
38 # define _(String) String
42 /* In the GNU C library, there is a predefined variable for this. */
44 # define program_name program_invocation_name
47 /* In GNU libc we want do not want to use the common name `error' directly.
48 Instead make it a weak alias. */
49 # define error __error
50 # define error_at_line __error_at_line
53 # include <libio/iolibio.h>
54 # define fflush(s) _IO_fflush (s)
59 /* The calling program should define program_name and set it to the
60 name of the executing program. */
61 extern char *program_name
;
64 # ifndef HAVE_DECL_STRERROR
65 "this configure-time declaration test was not run"
67 # if !HAVE_DECL_STRERROR && !defined strerror
72 private_strerror (int errnum
)
74 extern char *sys_errlist
[];
77 if (errnum
> 0 && errnum
<= sys_nerr
)
78 return _(sys_errlist
[errnum
]);
79 return _("Unknown system error");
81 # define strerror private_strerror
82 # endif /* HAVE_STRERROR */
83 #endif /* not _LIBC */
85 /* This variable is set each time `warn' is called. */
88 /* This variable is set each time `complain' is called. */
89 bool complaint_issued
;
92 /*--------------------------------.
93 | Report a warning, and proceed. |
94 `--------------------------------*/
97 warn_at (location_t location
, const char *message
, ...)
102 location_print (stderr
, location
);
103 fputs (": ", stderr
);
104 fputs (_("warning: "), stderr
);
106 va_start (args
, message
);
107 vfprintf (stderr
, message
, args
);
110 warning_issued
= true;
116 warn (const char *message
, ...)
121 fprintf (stderr
, "%s: %s", current_file
? current_file
: program_name
, _("warning: "));
123 va_start (args
, message
);
124 vfprintf (stderr
, message
, args
);
127 warning_issued
= true;
132 /*-----------------------------------------------------------.
133 | An error has occurred, but we can proceed, and die later. |
134 `-----------------------------------------------------------*/
137 complain_at (location_t location
, const char *message
, ...)
142 location_print (stderr
, location
);
143 fputs (": ", stderr
);
145 va_start (args
, message
);
146 vfprintf (stderr
, message
, args
);
149 complaint_issued
= true;
155 complain (const char *message
, ...)
160 fprintf (stderr
, "%s: ", current_file
? current_file
: program_name
);
162 va_start (args
, message
);
163 vfprintf (stderr
, message
, args
);
166 complaint_issued
= true;
171 /*-------------------------------------------------.
172 | A severe error has occurred, we cannot proceed. |
173 `-------------------------------------------------*/
176 fatal_at (location_t location
, const char *message
, ...)
181 location_print (stderr
, location
);
182 fputs (": ", stderr
);
183 fputs (_("fatal error: "), stderr
);
185 va_start (args
, message
);
186 vfprintf (stderr
, message
, args
);
194 fatal (const char *message
, ...)
199 fprintf (stderr
, "%s: ", current_file
? current_file
: program_name
);
201 fputs (_("fatal error: "), stderr
);
203 va_start (args
, message
);
204 vfprintf (stderr
, message
, args
);