]>
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)
33 # define _(String) String
36 /* The calling program should define program_name and set it to the
37 name of the executing program. */
38 extern char *program_name
;
41 # ifndef HAVE_DECL_STRERROR
42 "this configure-time declaration test was not run"
44 # if !HAVE_DECL_STRERROR && !defined strerror
49 private_strerror (int errnum
)
51 extern char *sys_errlist
[];
54 if (errnum
> 0 && errnum
<= sys_nerr
)
55 return _(sys_errlist
[errnum
]);
56 return _("Unknown system error");
58 # define strerror private_strerror
59 #endif /* HAVE_STRERROR */
61 /* This variable is set each time `warn' is called. */
64 /* This variable is set each time `complain' is called. */
65 bool complaint_issued
;
68 /*--------------------------------.
69 | Report a warning, and proceed. |
70 `--------------------------------*/
73 warn_at (location loc
, const char *message
, ...)
78 location_print (stderr
, loc
);
80 fputs (_("warning: "), stderr
);
82 va_start (args
, message
);
83 vfprintf (stderr
, message
, args
);
86 warning_issued
= true;
92 warn (const char *message
, ...)
97 fprintf (stderr
, "%s: %s", current_file
? current_file
: program_name
, _("warning: "));
99 va_start (args
, message
);
100 vfprintf (stderr
, message
, args
);
103 warning_issued
= true;
108 /*-----------------------------------------------------------.
109 | An error has occurred, but we can proceed, and die later. |
110 `-----------------------------------------------------------*/
113 complain_at (location loc
, const char *message
, ...)
118 location_print (stderr
, loc
);
119 fputs (": ", stderr
);
121 va_start (args
, message
);
122 vfprintf (stderr
, message
, args
);
125 complaint_issued
= true;
131 complain (const char *message
, ...)
136 fprintf (stderr
, "%s: ", current_file
? current_file
: program_name
);
138 va_start (args
, message
);
139 vfprintf (stderr
, message
, args
);
142 complaint_issued
= true;
147 /*-------------------------------------------------.
148 | A severe error has occurred, we cannot proceed. |
149 `-------------------------------------------------*/
152 fatal_at (location loc
, const char *message
, ...)
157 location_print (stderr
, loc
);
158 fputs (": ", stderr
);
159 fputs (_("fatal error: "), stderr
);
161 va_start (args
, message
);
162 vfprintf (stderr
, message
, args
);
170 fatal (const char *message
, ...)
175 fprintf (stderr
, "%s: ", current_file
? current_file
: program_name
);
177 fputs (_("fatal error: "), stderr
);
179 va_start (args
, message
);
180 vfprintf (stderr
, message
, args
);