2 /* Copyright (C) 1989, 1990, 1991, 1992, 2003, 2009
3 Free Software Foundation, Inc.
4 Written by James Clark (jjc@jclark.com)
6 This file is part of groff.
8 groff is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 extern void fatal_error_exit();
29 enum error_type { WARNING, ERROR, FATAL };
31 static void do_error_with_file_and_line(const char *filename,
32 const char *source_filename,
42 fprintf(stderr, "%s:", program_name);
45 if (lineno >= 0 && filename != 0) {
46 if (strcmp(filename, "-") == 0)
47 filename = "<standard input>";
48 if (source_filename != 0)
49 fprintf(stderr, "%s (%s):%d:", filename, source_filename, lineno);
51 fprintf(stderr, "%s:%d:", filename, lineno);
56 fputs("fatal error:", stderr);
62 fputs("warning:", stderr);
68 errprint(format, arg1, arg2, arg3);
76 static void do_error(error_type type,
82 do_error_with_file_and_line(current_filename, current_source_filename,
83 current_lineno, type, format, arg1, arg2, arg3);
87 void error(const char *format,
92 do_error(ERROR, format, arg1, arg2, arg3);
95 void warning(const char *format,
100 do_error(WARNING, format, arg1, arg2, arg3);
103 void fatal(const char *format,
108 do_error(FATAL, format, arg1, arg2, arg3);
111 void error_with_file_and_line(const char *filename,
118 do_error_with_file_and_line(filename, 0, lineno,
119 ERROR, format, arg1, arg2, arg3);
122 void warning_with_file_and_line(const char *filename,
129 do_error_with_file_and_line(filename, 0, lineno,
130 WARNING, format, arg1, arg2, arg3);
133 void fatal_with_file_and_line(const char *filename,
140 do_error_with_file_and_line(filename, 0, lineno,
141 FATAL, format, arg1, arg2, arg3);