change BEG header size info
[unix-history] / usr / src / usr.bin / pascal / libpc / ERROR.c
CommitLineData
0b85893f
KM
1/* Copyright (c) 1979 Regents of the University of California */
2
93ac5838 3static char sccsid[] = "@(#)ERROR.c 1.2 %G%";
0b85893f 4
e939d449
KM
5#include <stdio.h>
6#include <signal.h>
7#include "h00vars.h"
0b85893f
KM
8#include "h01errs.h"
9
10/*
11 * Routine ERROR is called from the runtime library when a runtime error
12 * occurs. Its arguments are the internal number of the error which occurred,
13 * and an error specific piece of error data. The error file is constructed
14 * from errdata by the makefile using the editor script make.ed1.
15 */
16ERROR(errnum, errdata)
17
18 long errnum;
19 union cvt {
20 long longdat;
21 char *strngdat;
22 double dbldat;
23 } errdata;
24{
25 PFLUSH();
e939d449
KM
26 if (_entry[errnum].entryaddr != 0) {
27 (*_entry[errnum].entryaddr)(errdata);
28 return;
29 }
0b85893f
KM
30 fputc('\n',stderr);
31 SETRACE();
32 switch (errnum) {
33 case ECHR:
34 fprintf(stderr, "Argument to chr of %d is out of range\n"
35 ,errdata.longdat);
36 return(errdata.longdat);
37 case EHALT:
38 fputs("Call to procedure halt\n",stderr);
39 PCEXIT(0);
40 case ENILPTR:
41 fputs("Pointer value out of legal range\n",stderr);
42 return(0);
43 case EPASTEOF:
44 fprintf(stderr,"%s: Tried to read past end of file\n"
45 ,errdata.strngdat);
46 return(0);
47 case EREADIT:
48 fprintf(stderr,"%s: Attempt to read, but open for writing\n"
49 ,errdata.strngdat);
50 return(0);
51 case EWRITEIT:
52 fprintf(stderr,"%s: Attempt to write, but open for reading\n"
53 ,errdata.strngdat);
54 return(0);
55 case ECLOSE:
56 fprintf(stderr,"%s: Close failed\n",errdata.strngdat);
57 return(0);
58 case ELLIMIT:
59 fprintf(stderr,"%s: Line limit exceeded\n",errdata.strngdat);
60 return(0);
61 case ESQRT:
62 fprintf(stderr,"Negative argument of %E to sqrt\n"
63 ,errdata.dbldat);
64 return(errdata.dbldat);
65 case EREFINAF:
66 fprintf(stderr,"%s: ",errdata.strngdat);
67 case ENOFILE:
68 fputs("Reference to an inactive file\n",stderr);
69 return(0);
70 case EWRITE:
71 fputs("Could not write to ",stderr);
72 perror(errdata.strngdat);
73 return(0);
74 case EOPEN:
75 fputs("Could not open ",stderr);
76 perror(errdata.strngdat);
77 return(0);
78 case ECREATE:
79 fputs("Could not create ",stderr);
80 perror(errdata.strngdat);
81 return(0);
82 case EREMOVE:
83 fputs("Could not remove ",stderr);
84 perror(errdata.strngdat);
85 return(0);
86 case ESEEK:
87 fputs("Could not reset ",stderr);
88 perror(errdata.strngdat);
89 return(0);
90 case ENAMESIZE:
91 fprintf(stderr,"%s: File name too long\n",errdata.strngdat);
92 return(0);
93 case ELN:
94 fprintf(stderr,"Non-positive argument of %E to ln\n"
95 ,errdata.dbldat);
96 return(errdata.dbldat);
97 case EBADINUM:
98 fprintf(stderr,"%s: Bad data found on integer read\n"
99 ,errdata.strngdat);
100 return(0);
101 case EBADFNUM:
102 fprintf(stderr,"%s: Bad data found on real read\n"
103 ,errdata.strngdat);
104 return(0);
105 case ENUMNTFD:
106 fprintf(stderr,
107 "Unknown name \"%s\" found on enumerated type read\n",
108 errdata.strngdat);
109 return(0);
110 case ENAMRNG:
111 fprintf(stderr,
112 "Enumerated type value of %d is out of range on output\n",
113 errdata.longdat);
114 return(errdata.longdat);
115 case EFMTSIZE:
116 fprintf(stderr,"Negative format width: %d\n",errdata.longdat);
117 return(0);
118 case EGOTO:
119 fputs("Active frame not found in non-local goto\n", stderr);
120 return(0);
121 case ECASE:
122 fprintf(stderr,"Label of %d not found in case\n"
123 ,errdata.longdat);
124 return(errdata.longdat);
125 case EOUTOFMEM:
126 fputs("Ran out of memory\n",stderr);
127 return(0);
128 case ECTLWR:
129 fprintf(stderr, "Range lower bound of %d out of set bounds\n",
130 errdata.longdat);
131 return(0);
132 case ECTUPR:
133 fprintf(stderr, "Range upper bound of %d out of set bounds\n",
134 errdata.longdat);
135 return(0);
136 case ECTSNG:
137 fprintf(stderr, "Value of %d out of set bounds\n",
138 errdata.longdat);
139 return(0);
140 case ENARGS:
141 if (errdata.longdat < 0)
142 fprintf(stderr,
143 "There were %d too few arguments to formal routine\n",
144 -errdata.longdat);
145 else
146 fprintf(stderr,
147 "There were %d too many arguments to formal routine\n",
148 errdata.longdat);
149 return(0);
150 case EARGV:
151 fprintf(stderr,"Argument to argv of %d is out of range\n"
152 ,errdata.longdat);
153 return(errdata.longdat);
154 case EPACK:
155 fprintf(stderr,"i = %d: Bad i to pack(a,i,z)\n"
156 ,errdata.longdat);
157 return(errdata.longdat);
158 case EUNPACK:
159 fprintf(stderr,"i = %d: Bad i to unpack(z,a,i)\n"
160 ,errdata.longdat);
161 return(errdata.longdat);
162 case ERANGE:
163 fprintf(stderr,"Value of %d is out of range\n",errdata.longdat);
164 return(errdata.longdat);
165 case ESUBSC:
166 fprintf(stderr,"Subscript value of %d is out of range\n"
167 ,errdata.longdat);
168 return(errdata.longdat);
169 case EASRT:
170 fprintf(stderr,"Assertion failed: %s\n",errdata.strngdat);
171 return(0);
172 case ESTLIM:
173 fprintf(stderr,
174 "Statement count limit exceeded, %d statements executed\n",
175 errdata.longdat);
176 return(errdata.longdat);
177 default:
178 fputs("Panic: unknown error\n",stderr);
179 return(0);
180 }
181}