-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.cpp
101 lines (87 loc) · 2.44 KB
/
error.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/******************************************************************************
* CVS version:
* $Id: error.c,v 1.2 2004/05/05 22:00:08 nickie Exp $
******************************************************************************
*
* C code file : error.c
* Project : PCL Compiler
* Version : 1.0 alpha
* Written by : Nikolaos S. Papaspyrou ([email protected])
* Date : May 14, 2003
* Description : Generic symbol table in C, simple error handler
*
* Comments: (in Greek iso-8859-7)
* ---------
* Åèíéêü Ìåôóüâéï Ðïëõôå÷íåßï.
* Ó÷ïëÞ Çëåêôñïëüãùí Ìç÷áíéêþí êáé Ìç÷áíéêþí Õðïëïãéóôþí.
* ÔïìÝáò Ôå÷íïëïãßáò ÐëçñïöïñéêÞò êáé Õðïëïãéóôþí.
* ÅñãáóôÞñéï Ôå÷íïëïãßáò Ëïãéóìéêïý
*/
/* ---------------------------------------------------------------------
---------------------------- Header files ---------------------------
--------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "general.h"
#include "error.h"
int errorCount = 0;
/* ---------------------------------------------------------------------
--------- Õëïðïßçóç ôùí óõíáñôÞóåùí ôïõ ÷åéñéóôÞ óöáëìÜôùí ----------
--------------------------------------------------------------------- */
void internal (const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt[0] == '\r')
fmt++;
else
fprintf(stderr, "%s:%d: ", filename, lineno);
fprintf(stderr, "Internal error, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(1);
}
void fatal (const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt[0] == '\r')
fmt++;
else
fprintf(stderr, "%s:%d: ", filename, lineno);
fprintf(stderr, "Fatal error, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(1);
}
void error (const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt[0] == '\r')
fmt++;
else
fprintf(stderr, "%s:%d: ", filename, lineno);
fprintf(stderr, "Error, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
if (++errorCount >= MAX_ERRORS)
exit(1);
}
void warning (const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt[0] == '\r')
fmt++;
else
fprintf(stderr, "%s:%d: ", filename, lineno);
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}