This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
98 lines (84 loc) · 2.57 KB
/
error.c
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
/******************************************************************************
* 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"
/* ---------------------------------------------------------------------
--------- Υλοποίηση των συναρτήσεων του χειριστή σφαλμάτων ----------
--------------------------------------------------------------------- */
void internal (const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt[0] == '\r')
fmt++;
else
fprintf(stderr, "%s:%d: ", filename, linecount);
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, linecount);
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, linecount);*/
fprintf(stderr, "Error, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}
void warning (const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt[0] == '\r')
fmt++;
else
fprintf(stderr, "%s:%d: ", filename, linecount);
fprintf(stderr, "Warning, ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}