diff options
author | obrien <obrien@FreeBSD.org> | 1999-08-26 09:30:50 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 1999-08-26 09:30:50 +0000 |
commit | 0bedf4fb30066e5e1d4342a1d3914dae7d37cba7 (patch) | |
tree | 68d8110b41afd0ebbf39167b1a4918eea667a7c5 /contrib/gcc/cpperror.c | |
parent | d4db5fb866b7ad5216abd5047774a3973b9901a9 (diff) | |
download | FreeBSD-src-0bedf4fb30066e5e1d4342a1d3914dae7d37cba7.zip FreeBSD-src-0bedf4fb30066e5e1d4342a1d3914dae7d37cba7.tar.gz |
Virgin import of gcc from EGCS 1.1.2
Diffstat (limited to 'contrib/gcc/cpperror.c')
-rw-r--r-- | contrib/gcc/cpperror.c | 95 |
1 files changed, 72 insertions, 23 deletions
diff --git a/contrib/gcc/cpperror.c b/contrib/gcc/cpperror.c index 5ba3b78..c4cac06 100644 --- a/contrib/gcc/cpperror.c +++ b/contrib/gcc/cpperror.c @@ -1,7 +1,7 @@ /* Default error handlers for CPP Library. - Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. + Copyright (C) 1986, 87, 89, 92 - 95, 1998 Free Software Foundation, Inc. Written by Per Bothner, 1994. - Based on CCCP program by by Paul Rubin, June 1986 + Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 This program is free software; you can redistribute it and/or modify it @@ -24,10 +24,18 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef EMACS #include "config.h" +#ifdef __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include "system.h" +#include "gansidecl.h" +#else +#include <stdio.h> #endif /* not EMACS */ #include "cpplib.h" -#include <stdio.h> /* Print the file names and line numbers of the #include commands which led to the current file. */ @@ -37,7 +45,6 @@ cpp_print_containing_files (pfile) cpp_reader *pfile; { cpp_buffer *ip; - int i; int first = 1; /* If stack of files hasn't changed since we last printed @@ -67,7 +74,7 @@ cpp_print_containing_files (pfile) fprintf (stderr, ",\n "); } - fprintf (stderr, " from %s:%d", ip->nominal_fname, line); + fprintf (stderr, " from %s:%ld", ip->nominal_fname, line); } if (! first) fprintf (stderr, ":\n"); @@ -78,7 +85,7 @@ cpp_print_containing_files (pfile) void cpp_file_line_for_message (pfile, filename, line, column) - cpp_reader *pfile; + cpp_reader *pfile ATTRIBUTE_UNUSED; char *filename; int line, column; { @@ -88,36 +95,78 @@ cpp_file_line_for_message (pfile, filename, line, column) fprintf (stderr, "%s:%d: ", filename, line); } -/* IS_ERROR is 1 for error, 0 for warning */ -void cpp_message (pfile, is_error, msg, arg1, arg2, arg3) - int is_error; - cpp_reader *pfile; - char *msg; - char *arg1, *arg2, *arg3; +/* IS_ERROR is 2 for "fatal" error, 1 for error, 0 for warning */ + +void +v_cpp_message (pfile, is_error, msg, ap) + cpp_reader * pfile; + int is_error; + const char *msg; + va_list ap; { - if (is_error) - pfile->errors++; - else + if (!is_error) fprintf (stderr, "warning: "); - fprintf (stderr, msg, arg1, arg2, arg3); + else if (is_error == 2) + pfile->errors = CPP_FATAL_LIMIT; + else if (pfile->errors < CPP_FATAL_LIMIT) + pfile->errors++; + vfprintf (stderr, msg, ap); fprintf (stderr, "\n"); } void -fatal (str, arg) - char *str, *arg; +cpp_message VPROTO ((cpp_reader *pfile, int is_error, const char *msg, ...)) { - fprintf (stderr, "%s: ", progname); - fprintf (stderr, str, arg); - fprintf (stderr, "\n"); - exit (FATAL_EXIT_CODE); +#ifndef __STDC__ + cpp_reader *pfile; + int is_error; + const char *msg; +#endif + va_list ap; + + VA_START (ap, msg); + +#ifndef __STDC__ + pfile = va_arg (ap, cpp_reader *); + is_error = va_arg (ap, int); + msg = va_arg (ap, const char *); +#endif + + v_cpp_message(pfile, is_error, msg, ap); + va_end(ap); } +/* Same as cpp_error, except we consider the error to be "fatal", + such as inconsistent options. I.e. there is little point in continuing. + (We do not exit, to support use of cpplib as a library. + Instead, it is the caller's responsibility to check + CPP_FATAL_ERRORS. */ + +void +cpp_fatal VPROTO ((cpp_reader *pfile, const char *str, ...)) +{ +#ifndef __STDC__ + cpp_reader *pfile; + const char *str; +#endif + va_list ap; + + VA_START (ap, str); + +#ifndef __STDC__ + pfile = va_arg (ap, cpp_reader *); + str = va_arg (ap, const char *); +#endif + + fprintf (stderr, "%s: ", progname); + v_cpp_message (pfile, 2, str, ap); + va_end(ap); +} void cpp_pfatal_with_name (pfile, name) cpp_reader *pfile; - char *name; + const char *name; { cpp_perror_with_name (pfile, name); #ifdef VMS |