|
|
1.1 ! root 1: /* Default error handlers for CPP Library. ! 2: Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc. ! 3: Written by Per Bothner, 1994. ! 4: Based on CCCP program by by Paul Rubin, June 1986 ! 5: Adapted to ANSI C, Richard Stallman, Jan 1987 ! 6: ! 7: This program is free software; you can redistribute it and/or modify it ! 8: under the terms of the GNU General Public License as published by the ! 9: Free Software Foundation; either version 2, or (at your option) any ! 10: later version. ! 11: ! 12: This program is distributed in the hope that it will be useful, ! 13: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 15: GNU General Public License for more details. ! 16: ! 17: You should have received a copy of the GNU General Public License ! 18: along with this program; if not, write to the Free Software ! 19: Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! 20: ! 21: In other words, you are welcome to use, share and improve this program. ! 22: You are forbidden to forbid anyone else to use, share and improve ! 23: what you give them. Help stamp out software-hoarding! */ ! 24: ! 25: #ifndef EMACS ! 26: #include "config.h" ! 27: #endif /* not EMACS */ ! 28: ! 29: #include "cpplib.h" ! 30: #include <stdio.h> ! 31: ! 32: /* Print the file names and line numbers of the #include ! 33: commands which led to the current file. */ ! 34: ! 35: void ! 36: cpp_print_containing_files (pfile) ! 37: cpp_reader *pfile; ! 38: { ! 39: cpp_buffer *ip; ! 40: int i; ! 41: int first = 1; ! 42: ! 43: /* If stack of files hasn't changed since we last printed ! 44: this info, don't repeat it. */ ! 45: if (pfile->input_stack_listing_current) ! 46: return; ! 47: ! 48: ip = cpp_file_buffer (pfile); ! 49: ! 50: /* Give up if we don't find a source file. */ ! 51: if (ip == NULL) ! 52: return; ! 53: ! 54: /* Find the other, outer source files. */ ! 55: while ((ip = CPP_PREV_BUFFER (ip)), ip != CPP_NULL_BUFFER (pfile)) ! 56: { ! 57: long line, col; ! 58: cpp_buf_line_and_col (ip, &line, &col); ! 59: if (ip->fname != NULL) ! 60: { ! 61: if (first) ! 62: { ! 63: first = 0; ! 64: fprintf (stderr, "In file included"); ! 65: } ! 66: else ! 67: fprintf (stderr, ",\n "); ! 68: } ! 69: ! 70: fprintf (stderr, " from %s:%d", ip->nominal_fname, line); ! 71: } ! 72: if (! first) ! 73: fprintf (stderr, ":\n"); ! 74: ! 75: /* Record we have printed the status as of this time. */ ! 76: pfile->input_stack_listing_current = 1; ! 77: } ! 78: ! 79: void ! 80: cpp_file_line_for_message (pfile, filename, line, column) ! 81: cpp_reader *pfile; ! 82: char *filename; ! 83: int line, column; ! 84: { ! 85: if (column > 0) ! 86: fprintf (stderr, "%s:%d:%d: ", filename, line, column); ! 87: else ! 88: fprintf (stderr, "%s:%d: ", filename, line); ! 89: } ! 90: ! 91: /* IS_ERROR is 1 for error, 0 for warning */ ! 92: void cpp_message (pfile, is_error, msg, arg1, arg2, arg3) ! 93: int is_error; ! 94: cpp_reader *pfile; ! 95: char *msg; ! 96: char *arg1, *arg2, *arg3; ! 97: { ! 98: if (is_error) ! 99: pfile->errors++; ! 100: else ! 101: fprintf (stderr, "warning: "); ! 102: fprintf (stderr, msg, arg1, arg2, arg3); ! 103: fprintf (stderr, "\n"); ! 104: } ! 105: ! 106: void ! 107: fatal (str, arg) ! 108: char *str, *arg; ! 109: { ! 110: fprintf (stderr, "%s: ", progname); ! 111: fprintf (stderr, str, arg); ! 112: fprintf (stderr, "\n"); ! 113: exit (FATAL_EXIT_CODE); ! 114: } ! 115: ! 116: ! 117: void ! 118: cpp_pfatal_with_name (pfile, name) ! 119: cpp_reader *pfile; ! 120: char *name; ! 121: { ! 122: cpp_perror_with_name (pfile, name); ! 123: #ifdef VMS ! 124: exit (vaxc$errno); ! 125: #else ! 126: exit (FATAL_EXIT_CODE); ! 127: #endif ! 128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.