2 /* Copyright (C) 1989, 1990, 1991, 1992 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
, int lineno
,
40 fprintf(stderr
, "%s:", program_name
);
43 if (lineno
>= 0 && filename
!= 0) {
44 if (strcmp(filename
, "-") == 0)
45 filename
= "<standard input>";
46 fprintf(stderr
, "%s:%d:", filename
, lineno
);
51 fputs("fatal error:", stderr
);
57 fputs("warning:", stderr
);
63 errprint(format
, arg1
, arg2
, arg3
);
71 static void do_error(error_type type
,
77 do_error_with_file_and_line(current_filename
, current_lineno
,
78 type
, format
, arg1
, arg2
, arg3
);
82 void error(const char *format
,
87 do_error(ERROR
, format
, arg1
, arg2
, arg3
);
90 void warning(const char *format
,
95 do_error(WARNING
, format
, arg1
, arg2
, arg3
);
98 void fatal(const char *format
,
103 do_error(FATAL
, format
, arg1
, arg2
, arg3
);
106 void error_with_file_and_line(const char *filename
,
113 do_error_with_file_and_line(filename
, lineno
,
114 ERROR
, format
, arg1
, arg2
, arg3
);
117 void warning_with_file_and_line(const char *filename
,
124 do_error_with_file_and_line(filename
, lineno
,
125 WARNING
, format
, arg1
, arg2
, arg3
);
128 void fatal_with_file_and_line(const char *filename
,
135 do_error_with_file_and_line(filename
, lineno
,
136 FATAL
, format
, arg1
, arg2
, arg3
);