-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
75 lines (58 loc) · 1.46 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
/*
* Copyright (c) 1997-2005 Alexandros Eleftheriadis, Danny Hong and
* Yuntai Kyong.
*
* This file is part of Flavor, developed at Columbia University
* (http://flavor.sourceforge.net).
*
* Flavor is free software; you can redistribute it and/or modify
* it under the terms of the Flavor Artistic License as described in
* the file COPYING.txt.
*
*/
/*
* Authors:
* Alexandros Eleftheriadis <[email protected]>
* Danny Hong <[email protected]>
* Yuntai Kyong <[email protected]>
*
*/
/* error.c */
/* error handling */
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "port.h"
#include "globals.h"
#include "error.h"
/* error handlers (note: almost all errors as handled via yyerror) */
void error(char *fmt, ...)
{
va_list ap;
/* keep track of how many errors we encountered */
nerrors++;
va_start(ap, fmt);
if (!msvc)
fprintf(stderr, "%s: ", program);
else
fprintf(stderr, "%s: error: ", program);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}
/* fatal error handler */
void fatal(char *fmt, ...)
{
va_list ap;
/* keep track of how many errors we encountered */
nerrors++;
va_start(ap, fmt);
if (!msvc)
fprintf(stderr, "%s: ", program);
else
fprintf(stderr, "%s: error: ", program);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(nerrors);
}