2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2003 Free Software Foundation, Inc.
5 * Written by James Clark (jjc@jclark.com)
7 * This 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 * This 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.
31 extern void fatal_error_exit(); // FIXME
33 enum error_type
{ WARNING
, ERROR
, FATAL
};
35 static void do_error_with_file_and_line(const char *filename
,
36 const char *source_filename
,
46 fprintf(stderr
, "%s:", program_name
);
49 if (lineno
>= 0 && filename
!= 0) {
50 if (strcmp(filename
, "-") == 0)
51 filename
= "<standard input>";
52 if (source_filename
!= 0)
53 fprintf(stderr
, "%s (%s):%d:", filename
, source_filename
, lineno
);
55 fprintf(stderr
, "%s:%d:", filename
, lineno
);
60 fputs("fatal error:", stderr
);
66 fputs("warning:", stderr
);
72 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
);
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
);