2 /* Copyright (C) 1989-2018 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 extern void fatal_error_exit();
28 enum error_type { WARNING, ERROR, FATAL };
30 static void do_error_with_file_and_line(const char *filename,
31 const char *source_filename,
41 fprintf(stderr, "%s:", program_name);
44 if (lineno >= 0 && filename != 0) {
45 if (strcmp(filename, "-") == 0)
46 filename = "<standard input>";
47 if (source_filename != 0)
48 fprintf(stderr, "%s (%s):%d:", filename, source_filename, lineno);
50 fprintf(stderr, "%s:%d:", filename, lineno);
59 fputs("fatal error:", stderr);
65 fputs("warning:", stderr);
71 errprint(format, arg1, arg2, arg3);
79 static void do_error(error_type type,
85 do_error_with_file_and_line(current_filename, current_source_filename,
86 current_lineno, type, format, arg1, arg2, arg3);
90 void error(const char *format,
95 do_error(ERROR, format, arg1, arg2, arg3);
98 void warning(const char *format,
103 do_error(WARNING, format, arg1, arg2, arg3);
106 void fatal(const char *format,
111 do_error(FATAL, format, arg1, arg2, arg3);
114 void error_with_file_and_line(const char *filename,
121 do_error_with_file_and_line(filename, 0, lineno,
122 ERROR, format, arg1, arg2, arg3);
125 void warning_with_file_and_line(const char *filename,
132 do_error_with_file_and_line(filename, 0, lineno,
133 WARNING, format, arg1, arg2, arg3);
136 void fatal_with_file_and_line(const char *filename,
143 do_error_with_file_and_line(filename, 0, lineno,
144 FATAL, format, arg1, arg2, arg3);