]>
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 
  37 # define _(String) String 
  41 /* In the GNU C library, there is a predefined variable for this.  */ 
  43 # define program_name program_invocation_name 
  46 /* In GNU libc we want do not want to use the common name `error' directly. 
  47    Instead make it a weak alias.  */ 
  48 # define error __error 
  49 # define error_at_line __error_at_line 
  52 #  include <libio/iolibio.h> 
  53 #  define fflush(s) _IO_fflush (s) 
  58 /* The calling program should define program_name and set it to the 
  59    name of the executing program.  */ 
  60 extern char *program_name
; 
  63 #  ifndef HAVE_DECL_STRERROR 
  64 "this configure-time declaration test was not run" 
  66 #  if !HAVE_DECL_STRERROR && !defined strerror 
  71 private_strerror (int errnum
) 
  73   extern char *sys_errlist
[]; 
  76   if (errnum 
> 0 && errnum 
<= sys_nerr
) 
  77     return _(sys_errlist
[errnum
]); 
  78   return _("Unknown system error"); 
  80 #  define strerror private_strerror 
  81 # endif /* HAVE_STRERROR */ 
  82 #endif  /* not _LIBC */ 
  84 /* This variable is set each time `warn' is called.  */ 
  87 /* This variable is set each time `complain' is called.  */ 
  88 bool complaint_issued
; 
  91 /*--------------------------------. 
  92 | Report a warning, and proceed.  | 
  93 `--------------------------------*/ 
  96 warn_at (location_t location
, const char *message
, ...) 
 101   LOCATION_PRINT (stderr
, location
); 
 102   fputs (": ", stderr
); 
 103   fputs (_("warning: "), stderr
); 
 105   va_start (args
, message
); 
 106   vfprintf (stderr
, message
, args
); 
 109   warning_issued 
= true; 
 115 warn (const char *message
, ...) 
 120   fprintf (stderr
, "%s: %s", infile 
? infile 
: program_name
, _("warning: ")); 
 122   va_start (args
, message
); 
 123   vfprintf (stderr
, message
, args
); 
 126   warning_issued 
= true; 
 131 /*-----------------------------------------------------------. 
 132 | An error has occurred, but we can proceed, and die later.  | 
 133 `-----------------------------------------------------------*/ 
 136 complain_at (location_t location
, const char *message
, ...) 
 141   LOCATION_PRINT (stderr
, location
); 
 142   fputs (": ", stderr
); 
 144   va_start (args
, message
); 
 145   vfprintf (stderr
, message
, args
); 
 148   complaint_issued 
= true; 
 154 complain (const char *message
, ...) 
 159   fprintf (stderr
, "%s: ", infile 
? infile 
: program_name
); 
 161   va_start (args
, message
); 
 162   vfprintf (stderr
, message
, args
); 
 165   complaint_issued 
= true; 
 170 /*-------------------------------------------------. 
 171 | A severe error has occurred, we cannot proceed.  | 
 172 `-------------------------------------------------*/ 
 175 fatal_at (location_t location
, const char *message
, ...) 
 180   LOCATION_PRINT (stderr
, location
); 
 181   fputs (": ", stderr
); 
 182   fputs (_("fatal error: "), stderr
); 
 184   va_start (args
, message
); 
 185   vfprintf (stderr
, message
, args
); 
 193 fatal (const char *message
, ...) 
 198   fprintf (stderr
, "%s: ", infile 
? infile 
: program_name
); 
 200   fputs (_("fatal error: "), stderr
); 
 202   va_start (args
, message
); 
 203   vfprintf (stderr
, message
, args
);