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
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
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA.
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! */
30 /* Print the file names and line numbers of the #include
31 * commands which led to the current file. */
34 cpp_print_containing_files(cpp_reader * pfile)
39 /* If stack of files hasn't changed since we last printed
40 * this info, don't repeat it. */
41 if (pfile->input_stack_listing_current)
44 ip = cpp_file_buffer(pfile);
46 /* Give up if we don't find a source file. */
50 /* Find the other, outer source files. */
51 while ((ip = CPP_PREV_BUFFER(ip)), ip != CPP_NULL_BUFFER(pfile))
55 cpp_buf_line_and_col(ip, &line, &col);
56 if (ip->fname != NULL)
61 fprintf(stderr, "In file included");
64 fprintf(stderr, ",\n ");
68 fprintf(stderr, ":\n");
70 /* Record we have printed the status as of this time. */
71 pfile->input_stack_listing_current = 1;
75 cpp_file_line_for_message(cpp_reader * pfile, const char *filename,
81 fprintf(stderr, "%s:%d:%d: ", filename, line, column);
85 fprintf(stderr, "%s:%d: ", filename, line);
89 /* IS_ERROR is 1 for error, 0 for warning */
91 cpp_message_v(cpp_reader * pfile, int is_error, const char *msg, va_list args)
96 fprintf(stderr, "warning: ");
97 vfprintf(stderr, msg, args);
98 fprintf(stderr, "\n");
102 cpp_message(cpp_reader * pfile, int is_error, const char *msg, ...)
108 cpp_message_v(pfile, is_error, msg, args);
114 cpp_fatal_v(const char *msg, va_list args)
116 fprintf(stderr, "%s: ", progname);
117 vfprintf(stderr, msg, args);
118 fprintf(stderr, "\n");
119 exit(FATAL_EXIT_CODE);
123 cpp_fatal(const char *msg, ...)
129 cpp_fatal_v(msg, args);
135 cpp_pfatal_with_name(cpp_reader * pfile, const char *name)
137 cpp_perror_with_name(pfile, name);
141 exit(FATAL_EXIT_CODE);