* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / unproto / error.c
blob667d978cbb60eedc95ad51e0ca0cd75ac17c5c08
1 /*++
2 /* NAME
3 /* error 3
4 /* SUMMARY
5 /* diagnostics
6 /* PACKAGE
7 /* unproto
8 /* SYNOPSIS
9 /* #include "error.h"
11 /* int errcount;
13 /* void error(text)
14 /* char *text;
16 /* void error_where(path, line, text)
17 /* char *path;
18 /* int line;
19 /* char *text;
21 /* void fatal(text)
22 /* char *text;
23 /* DESCRIPTION
24 /* The routines in this file print a diagnostic (text). Some also
25 /* terminate the program. Upon each error*() call, the errcount variable
26 /* is incremented.
28 /* error() provides a default context, i.e. the source-file
29 /* coordinate of the last read token.
31 /* error_where() allows the caller to explicitly specify context: path
32 /* is a source-file name, and line is a line number.
34 /* fatal() is like error() but terminates the program with a non-zero
35 /* exit status.
37 /* context is ignored if the line number is zero or if the path
38 /* is an empty string.
39 /* AUTHOR(S)
40 /* Wietse Venema
41 /* Eindhoven University of Technology
42 /* Department of Mathematics and Computer Science
43 /* Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
44 /* LAST MODIFICATION
45 /* 92/01/15 21:53:10
46 /* VERSION/RELEASE
47 /* 1.2
48 /*--*/
50 static char error_sccsid[] = "@(#) error.c 1.2 92/01/15 21:53:10";
52 /* C library */
54 #include <stdio.h>
56 extern void exit();
58 /* Application-specific stuff */
60 #include "token.h"
61 #include "error.h"
63 int errcount = 0; /* error counter */
65 /* error - report problem (implicit context) */
67 void error(text)
68 char *text;
70 error_where(in_path, in_line, text);
73 /* error_where - report problem (explicit context) */
75 void error_where(path, line, text)
76 char *path;
77 int line;
78 char *text;
80 errcount++;
82 /* Suppress context info if there is none. */
84 if (line && path[0])
85 fprintf(stderr, "%s, line %d: ", path, line);
87 fprintf(stderr, "%s\n", text);
90 /* fatal - report problem and terminate unsuccessfully */
92 void fatal(text)
93 char *text;
95 error(text);
96 exit(1);