]>
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
, ...)
77 location_print (stderr
, loc
);
79 fputs (_("warning: "), stderr
);
81 va_start (args
, message
);
82 vfprintf (stderr
, message
, args
);
85 warning_issued
= true;
90 warn (const char *message
, ...)
94 fprintf (stderr
, "%s: %s", current_file
? current_file
: program_name
, _("warning: "));
96 va_start (args
, message
);
97 vfprintf (stderr
, message
, args
);
100 warning_issued
= true;
104 /*-----------------------------------------------------------.
105 | An error has occurred, but we can proceed, and die later. |
106 `-----------------------------------------------------------*/
109 complain_at (location loc
, const char *message
, ...)
113 location_print (stderr
, loc
);
114 fputs (": ", stderr
);
116 va_start (args
, message
);
117 vfprintf (stderr
, message
, args
);
120 complaint_issued
= true;
125 complain (const char *message
, ...)
129 fprintf (stderr
, "%s: ", current_file
? current_file
: program_name
);
131 va_start (args
, message
);
132 vfprintf (stderr
, message
, args
);
135 complaint_issued
= true;
139 /*-------------------------------------------------.
140 | A severe error has occurred, we cannot proceed. |
141 `-------------------------------------------------*/
144 fatal_at (location loc
, const char *message
, ...)
148 location_print (stderr
, loc
);
149 fputs (": ", stderr
);
150 fputs (_("fatal error: "), stderr
);
152 va_start (args
, message
);
153 vfprintf (stderr
, message
, args
);
160 fatal (const char *message
, ...)
164 fprintf (stderr
, "%s: ", current_file
? current_file
: program_name
);
166 fputs (_("fatal error: "), stderr
);
168 va_start (args
, message
);
169 vfprintf (stderr
, message
, args
);