new copyright; att/bsd/shared
[unix-history] / usr / src / usr.bin / pascal / pxp / error.c
CommitLineData
0fc6e47b
KB
1/*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
252367af
DF
6 */
7
8#ifndef lint
0fc6e47b
KB
9static char sccsid[] = "@(#)error.c 5.3 (Berkeley) %G%";
10#endif /* not lint */
252367af 11
6ef1487c
PK
12/*
13 * pi - Pascal interpreter code translator
14 *
15 * Charles Haley, Bill Joy UCB
16 * Version 1.2 January 1979
17 *
18 *
19 * pxp - Pascal execution profiler
20 *
21 * Bill Joy UCB
22 * Version 1.2 January 1979
23 */
24
84ef74c0 25#include "whoami.h"
6ef1487c
PK
26#include "0.h"
27#include "yy.h"
28
29#ifdef PXP
30extern int yyline;
31extern char errout;
32#endif
33
f4e01610 34char errpfx = 'E';
6ef1487c
PK
35extern int yyline;
36/*
37 * Panic is called when impossible
38 * (supposedly, anyways) situations
39 * are encountered.
40#ifdef PI
41 * Panic messages should be short
42 * as they do not go to the message
43 * file.
44#endif
45 */
46panic(s)
47 char *s;
48{
49
50#ifdef DEBUG
51 fprintf(stderr, "Snark (%s) line=%d yyline=%d\n", s, line, yyline);
52#endif
53#ifdef PXP
54 Perror( "Snark in pxp", s);
55#endif
56#ifdef PI
57 Perror( "Snark in pi", s);
58#endif
59 pexit(DIED);
60}
61
62extern char *errfile;
63/*
64 * Error is called for
65 * semantic errors and
66 * prints the error and
67 * a line number.
68 */
69error(a1, a2, a3, a4)
70{
71#ifdef PI
72 char buf[256];
73 register int i;
74#endif
75#ifdef PXP
76/*
77 int ofout;
78*/
79#endif
80
8e00b863
PK
81 if (errpfx == 'w' && opt('w') != 0) {
82 errpfx == 'E';
6ef1487c 83 return;
8e00b863 84 }
6ef1487c
PK
85#ifdef PXP
86/*
87 flush();
88 ofout = fout[0];
89 fout[0] = errout;
90*/
91#endif
92#ifdef PI
93 Enocascade = 0;
94 geterr(a1, buf);
95 a1 = buf;
96#endif
97 if (line < 0)
98 line = -line;
99 yySsync();
100 yysetfile(filename);
101#ifdef PI
102 if (errpfx == ' ') {
103 printf(" ");
7169b77a 104 for (i = line; i >= 10; i /= 10)
6ef1487c
PK
105 putchar(' ');
106 printf("... ");
107 } else if (Enoline)
108 printf(" %c - ", errpfx);
109 else
110#endif
111 fprintf(stderr, "%c %d - ", errpfx, line);
112 fprintf(stderr, a1, a2, a3, a4);
113 if (errpfx == 'E')
114#ifdef PI
115 eflg++, cgenflg++;
116#endif
117#ifdef PXP
118 eflg++;
119#endif
120 errpfx = 'E';
121#ifdef PI
122 if (Eholdnl)
123 Eholdnl = 0;
124 else
125#endif
126 putc('\n', stderr);
127#ifdef PXP
128/*
129 flush();
130 fout[0] = ofout;
131*/
132#endif
133}
134
135#ifdef PI
136cerror(a1, a2, a3, a4)
137{
138
139 if (Enocascade)
140 return;
141 setpfx(' ');
142 error(a1, a2, a3, a4);
143}
144#endif