|
|
1.1 root 1: /* Copyright (c) 1979 Regents of the University of California */
2:
3: static char sccsid[] = "@(#)error.c 1.1 8/27/80";
4:
5: #include "whoami.h"
6: #include "0.h"
7: #ifndef PI1
8: #include "yy.h"
9: #endif
10:
11: char errpfx = 'E';
12: extern int yyline;
13: /*
14: * Panic is called when impossible
15: * (supposedly, anyways) situations
16: * are encountered.
17: * Panic messages should be short
18: * as they do not go to the message
19: * file.
20: */
21: panic(s)
22: char *s;
23: {
24:
25: #ifdef DEBUG
26: #ifdef PI1
27: printf("Snark (%s) line=%d\n", s, line);
28: abort();
29: #else
30: printf("Snark (%s) line=%d, yyline=%d\n", s, line, yyline);
31: abort () ; /* die horribly */
32: #endif
33: #endif
34: #ifdef PI1
35: Perror( "Snark in pi1", s);
36: #else
37: Perror( "Snark in pi", s);
38: #endif
39: pexit(DIED);
40: }
41:
42: extern char *errfile;
43: /*
44: * Error is called for
45: * semantic errors and
46: * prints the error and
47: * a line number.
48: */
49:
50: /*VARARGS*/
51:
52: error(a1, a2, a3, a4)
53: register char *a1;
54: {
55: char errbuf[256]; /* was extern. why? ...pbk */
56: register int i;
57:
58: if (errpfx == 'w' && opt('w') != 0) {
59: errpfx = 'E';
60: return;
61: }
62: Enocascade = 0;
63: geterr(a1, errbuf);
64: a1 = errbuf;
65: if (line < 0)
66: line = -line;
67: #ifndef PI1
68: if (opt('l'))
69: yyoutline();
70: #endif
71: yysetfile(filename);
72: if (errpfx == ' ') {
73: printf(" ");
74: for (i = line; i >= 10; i /= 10)
75: pchr( ' ' );
76: printf("... ");
77: } else if (Enoline)
78: printf(" %c - ", errpfx);
79: else
80: printf("%c %d - ", errpfx, line);
81: printf(a1, a2, a3, a4);
82: if (errpfx == 'E')
83: #ifndef PI0
84: eflg++, codeoff();
85: #else
86: eflg++;
87: #endif
88: errpfx = 'E';
89: if (Eholdnl)
90: Eholdnl = 0;
91: else
92: pchr( '\n' );
93: }
94:
95: /*VARAGRS*/
96:
97: cerror(a1, a2, a3, a4)
98: {
99:
100: if (Enocascade)
101: return;
102: setpfx(' ');
103: error(a1, a2, a3, a4);
104: }
105:
106: #ifdef PI1
107:
108: /*VARARGS*/
109:
110: derror(a1, a2, a3, a4)
111: {
112:
113: if (!holdderr)
114: error(a1, a2, a3, a4);
115: errpfx = 'E';
116: }
117:
118: char *lastname, printed, hadsome;
119:
120: /*
121: * this yysetfile for PI1 only.
122: * the real yysetfile is in yyput.c
123: */
124: yysetfile(name)
125: char *name;
126: {
127:
128: if (lastname == name)
129: return;
130: printed =| 1;
131: gettime( name );
132: printf("%s %s:\n" , myctime( &tvec ) , name );
133: lastname = name;
134: }
135: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.