2 Copyright (C) 2005,2006,2007,2008 Eugene K. Ressler, Jr.
4 This file is part of Sketch, a small, simple system for making
5 3d drawings with LaTeX and the PSTricks or TikZ package.
7 Sketch is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 Sketch is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Sketch; see the file COPYING.txt. If not, see
19 http://www.gnu.org/copyleft */
26 SRC_LINE no_line
= { NULL
, 0 };
28 typedef enum error_type_t
34 E_N
// keep last; this is the number of error types
38 char *error_type_str
[] = {
45 static int n_errors
[E_N
]; // assumes C initialization to zero
48 print_error (ERROR_TYPE type
, SRC_LINE line
, char *fmt
, va_list arg_list
)
52 fprintf (stderr
, "%s", line
.file_name
);
54 fprintf (stderr
, "(%u) : ", line
.number
);
55 fprintf (stderr
, "%s, ", error_type_str
[type
]);
56 vfprintf (stderr
, fmt
, arg_list
);
57 fprintf (stderr
, "\n");
61 remark (SRC_LINE line
, char *fmt
, ...)
65 va_start (arg_list
, fmt
);
66 print_error (E_REMARK
, line
, fmt
, arg_list
);
71 warn (SRC_LINE line
, char *fmt
, ...)
75 va_start (arg_list
, fmt
);
76 print_error (E_WARNING
, line
, fmt
, arg_list
);
81 err (SRC_LINE line
, char *fmt
, ...)
85 va_start (arg_list
, fmt
);
86 print_error (E_ERROR
, line
, fmt
, arg_list
);
91 die (SRC_LINE line
, char *fmt
, ...)
95 va_start (arg_list
, fmt
);
96 print_error (E_FATAL_ERROR
, line
, fmt
, arg_list
);
104 return n_errors
[E_ERROR
] > 0 || n_errors
[E_FATAL_ERROR
] > 0;
112 // start printing summary
113 fprintf (stderr
, "summary: ");
114 for (i
= 0; i
< E_N
; i
++)
119 fprintf (stderr
, ", ");
120 fprintf (stderr
, "%d %s", n_errors
[i
], error_type_str
[i
]);
125 // see if we need to abort
128 fprintf (stderr
, "\nquitting...\n");
131 // not aborting, so finish up the summary
134 fprintf (stderr
, "no errors");
136 fprintf (stderr
, "\n");
138 // zero the error counters
139 for (i
= 0; i
< E_N
; i
++)