diff options
author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-04-05 20:34:58 +0000 |
---|---|---|
committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-04-05 20:34:58 +0000 |
commit | ad0e2334a8dbbaec4d046a4929b08571197a8ec8 (patch) | |
tree | 3f19a4877af3ab4b37d888910ed26b0c9b498db6 /gcc/cpperror.c | |
parent | 55f69bde59bbf1aabfcf87b3c2987435b574a7a2 (diff) | |
download | gcc-ad0e2334a8dbbaec4d046a4929b08571197a8ec8.tar.gz |
Moved 'high-level' error functions from cpperror.c to cpplib.c.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@9315 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpperror.c')
-rw-r--r-- | gcc/cpperror.c | 226 |
1 files changed, 10 insertions, 216 deletions
diff --git a/gcc/cpperror.c b/gcc/cpperror.c index 982bcc33449..33e2c01188d 100644 --- a/gcc/cpperror.c +++ b/gcc/cpperror.c @@ -25,27 +25,6 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. #include "cpplib.h" #include <stdio.h> -/* This defines "errno" properly for VMS, and gives us EACCES. */ -#include <errno.h> -#ifndef errno -extern int errno; -#endif - -#ifndef VMS -#ifndef HAVE_STRERROR -extern int sys_nerr; -#if defined(bsd4_4) -extern const char *const sys_errlist[]; -#else -extern char *sys_errlist[]; -#endif -#else /* HAVE_STERRROR */ -char *strerror (); -#endif -#else /* VMS */ -char *strerror (int,...); -#endif - /* Print the file names and line numbers of the #include commands which led to the current file. */ @@ -102,147 +81,25 @@ cpp_print_containing_files (pfile) } void -cpp_print_file_and_line (pfile) - cpp_reader *pfile; -{ - cpp_buffer *ip = cpp_file_buffer (pfile); - - if (ip != NULL) - { - long line, col; - cpp_buf_line_and_col (ip, &line, &col); - if (pfile->show_column) - fprintf (stderr, "%s:%d:%d: ", ip->nominal_fname, line, col); - else - fprintf (stderr, "%s:%d: ", ip->nominal_fname, line); - } -} - -void -cpp_error (pfile, msg, arg1, arg2, arg3) - cpp_reader *pfile; - char *msg; - char *arg1, *arg2, *arg3; -{ - cpp_print_containing_files (pfile); - cpp_print_file_and_line (pfile); - fprintf (stderr, msg, arg1, arg2, arg3); - fprintf (stderr, "\n"); - pfile->errors++; -} - -/* Print error message but don't count it. */ - -void -cpp_warning (pfile, msg, arg1, arg2, arg3) - cpp_reader *pfile; - char *msg; - char *arg1, *arg2, *arg3; -{ - if (CPP_OPTIONS (pfile)->inhibit_warnings) - return; - - if (CPP_OPTIONS (pfile)->warnings_are_errors) - pfile->errors++; - - cpp_print_containing_files (pfile); - cpp_print_file_and_line (pfile); - fprintf (stderr, "warning: "); - fprintf (stderr, msg, arg1, arg2, arg3); - fprintf (stderr, "\n"); -} - -void -cpp_error_with_line (pfile, line, msg, arg1, arg2, arg3) - cpp_reader *pfile; - int line; - char *msg; - char *arg1, *arg2, *arg3; -{ - int i; - cpp_buffer *ip = cpp_file_buffer (pfile); - - cpp_print_containing_files (pfile); - - if (ip != NULL) - fprintf (stderr, "%s:%d: ", ip->nominal_fname, line); - - fprintf (stderr, msg, arg1, arg2, arg3); - fprintf (stderr, "\n"); - pfile->errors++; -} - -void -cpp_warning_with_line (pfile, line, msg, arg1, arg2, arg3) - cpp_reader *pfile; - int line; - char *msg; - char *arg1, *arg2, *arg3; -{ - int i; - cpp_buffer *ip; - - if (CPP_OPTIONS (pfile)->inhibit_warnings) - return; - - if (CPP_OPTIONS (pfile)->warnings_are_errors) - pfile->errors++; - - cpp_print_containing_files (pfile); - - ip = cpp_file_buffer (pfile); - - if (ip != NULL) - fprintf (stderr, "%s:%d: ", ip->nominal_fname, line); - fprintf (stderr, "warning: "); - fprintf (stderr, msg, arg1, arg2, arg3); - fprintf (stderr, "\n"); -} - -/* Print an error message and maybe count it. */ - -void -cpp_pedwarn (pfile, msg, arg1, arg2, arg3) +cpp_file_line_for_message (pfile, filename, line, column) cpp_reader *pfile; - char *msg; - char *arg1, *arg2, *arg3; -{ - if (CPP_OPTIONS (pfile)->pedantic_errors) - cpp_error (pfile, msg, arg1, arg2, arg3); - else - cpp_warning (pfile, msg, arg1, arg2, arg3); -} - -void -cpp_pedwarn_with_line (pfile, line, msg, arg1, arg2, arg3) - cpp_reader *pfile; - int line; - char *msg; - char *arg1, *arg2, *arg3; + char *filename; + int line, column; { - if (CPP_OPTIONS (pfile)->pedantic_errors) - cpp_error_with_line (pfile, line, msg, arg1, arg2, arg3); + if (column > 0) + fprintf (stderr, "%s:%d:%d: ", filename, line, column); else - cpp_warning_with_line (pfile, line, msg, arg1, arg2, arg3); + fprintf (stderr, "%s:%d: ", filename, line); } -/* Report a warning (or an error if pedantic_errors) - giving specified file name and line number, not current. */ - -void -cpp_pedwarn_with_file_and_line (pfile, file, line, msg, arg1, arg2, arg3) +/* 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 *file; - int line; char *msg; char *arg1, *arg2, *arg3; { - if (!CPP_OPTIONS (pfile)->pedantic_errors - && CPP_OPTIONS (pfile)->inhibit_warnings) - return; - if (file != NULL) - fprintf (stderr, "%s:%d: ", file, line); - if (CPP_OPTIONS (pfile)->pedantic_errors) + if (is_error) pfile->errors++; else fprintf (stderr, "warning: "); @@ -261,69 +118,6 @@ fatal (str, arg) } -/* - * my_strerror - return the descriptive text associated with an `errno' code. - */ - -char * -my_strerror (errnum) - int errnum; -{ - char *result; - -#ifndef VMS -#ifndef HAVE_STRERROR - result = (char *) ((errnum < sys_nerr) ? sys_errlist[errnum] : 0); -#else - result = strerror (errnum); -#endif -#else /* VMS */ - /* VAXCRTL's strerror() takes an optional second argument, which only - matters when the first argument is EVMSERR. However, it's simplest - just to pass it unconditionally. `vaxc$errno' is declared in - <errno.h>, and maintained by the library in parallel with `errno'. - We assume that caller's `errnum' either matches the last setting of - `errno' by the library or else does not have the value `EVMSERR'. */ - - result = strerror (errnum, vaxc$errno); -#endif - - if (!result) - result = "undocumented I/O error"; - - return result; -} - -/* Error including a message from `errno'. */ - -void -cpp_error_from_errno (pfile, name) - cpp_reader *pfile; - char *name; -{ - int i; - cpp_buffer *ip = cpp_file_buffer (pfile); - - cpp_print_containing_files (pfile); - - if (ip != NULL) - fprintf (stderr, "%s:%d: ", ip->nominal_fname, ip->lineno); - - fprintf (stderr, "%s: %s\n", name, my_strerror (errno)); - - pfile->errors++; -} - -void -cpp_perror_with_name (pfile, name) - cpp_reader *pfile; - char *name; -{ - fprintf (stderr, "%s: ", progname); - fprintf (stderr, "%s: %s\n", name, my_strerror (errno)); - pfile->errors++; -} - void cpp_pfatal_with_name (pfile, name) cpp_reader *pfile; |