2 /* Copyright (C) 1989, 1990, 1991, 1992, 2003 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 2, or (at your option) any later
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 along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
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);