4 /* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
29 extern void fatal_error_exit();
31 enum error_type
{ WARNING
, ERROR
, FATAL
};
33 static void do_error_with_file_and_line(const char *filename
,
34 const char *source_filename
,
44 fprintf(stderr
, "%s:", program_name
);
47 if (lineno
>= 0 && filename
!= 0) {
48 if (strcmp(filename
, "-") == 0)
49 filename
= "<standard input>";
50 if (source_filename
!= 0)
51 fprintf(stderr
, "%s (%s):%d:", filename
, source_filename
, lineno
);
53 fprintf(stderr
, "%s:%d:", filename
, lineno
);
58 fputs("fatal error:", stderr
);
64 fputs("warning:", stderr
);
70 errprint(format
, arg1
, arg2
, arg3
);
78 static void do_error(error_type type
,
84 do_error_with_file_and_line(current_filename
, current_source_filename
,
85 current_lineno
, type
, format
, arg1
, arg2
, arg3
);
89 void error(const char *format
,
94 do_error(ERROR
, format
, arg1
, arg2
, arg3
);
97 void warning(const char *format
,
102 do_error(WARNING
, format
, arg1
, arg2
, arg3
);
105 void fatal(const char *format
,
110 do_error(FATAL
, format
, arg1
, arg2
, arg3
);
113 void error_with_file_and_line(const char *filename
,
120 do_error_with_file_and_line(filename
, 0, lineno
,
121 ERROR
, format
, arg1
, arg2
, arg3
);
124 void warning_with_file_and_line(const char *filename
,
131 do_error_with_file_and_line(filename
, 0, lineno
,
132 WARNING
, format
, arg1
, arg2
, arg3
);
135 void fatal_with_file_and_line(const char *filename
,
142 do_error_with_file_and_line(filename
, 0, lineno
,
143 FATAL
, format
, arg1
, arg2
, arg3
);