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 * Copyright (C) 2003-2011 Kim Woelders
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 * In other words, you are welcome to use, share and improve this program.
23 * You are forbidden to forbid anyone else to use, share and improve
24 * what you give them. Help stamp out software-hoarding! */
35 /* Print the file names and line numbers of the #include
36 * commands which led to the current file. */
39 cpp_print_containing_files(cpp_reader * pfile)
44 /* If stack of files hasn't changed since we last printed
45 * this info, don't repeat it. */
46 if (pfile->input_stack_listing_current)
49 ip = cpp_file_buffer(pfile);
51 /* Give up if we don't find a source file. */
55 /* Find the other, outer source files. */
56 while ((ip = CPP_PREV_BUFFER(ip)), ip != CPP_NULL_BUFFER(pfile))
60 cpp_buf_line_and_col(ip, &line, &col);
66 fprintf(stderr, "In file included");
69 fprintf(stderr, ",\n ");
73 fprintf(stderr, ":\n");
75 /* Record we have printed the status as of this time. */
76 pfile->input_stack_listing_current = 1;
80 cpp_file_line_for_message(cpp_reader * pfile __UNUSED__, const char *filename,
85 fprintf(stderr, "%s:%d:%d: ", filename, line, column);
89 fprintf(stderr, "%s:%d: ", filename, line);
93 /* IS_ERROR is 1 for error, 0 for warning */
95 cpp_message_v(cpp_reader * pfile, int is_error, const char *msg, va_list args)
100 fprintf(stderr, "warning: ");
101 vfprintf(stderr, msg, args);
102 fprintf(stderr, "\n");
106 cpp_message(cpp_reader * pfile, int is_error, const char *msg, ...)
112 cpp_message_v(pfile, is_error, msg, args);
118 cpp_fatal_v(const char *msg, va_list args)
120 fprintf(stderr, "%s: ", progname);
121 vfprintf(stderr, msg, args);
122 fprintf(stderr, "\n");
123 exit(FATAL_EXIT_CODE);
127 cpp_fatal(const char *msg, ...)
133 cpp_fatal_v(msg, args);
139 cpp_pfatal_with_name(cpp_reader * pfile, const char *name)
141 cpp_perror_with_name(pfile, name);
145 exit(FATAL_EXIT_CODE);