put display save area back into formal routine structure
[unix-history] / usr / src / usr.bin / pascal / libpc / ERROR.c
CommitLineData
0b85893f
KM
1/* Copyright (c) 1979 Regents of the University of California */
2
d3fdcc0c 3static char sccsid[] = "@(#)ERROR.c 1.7 %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 */
492cc5d3 16long
d3fdcc0c 17ERROR(msg, d1, d2, d3, d4)
0b85893f 18
d3fdcc0c
KM
19 char *msg;
20 int d1, d2, d3, d4;
21{
0b85893f 22 union cvt {
d3fdcc0c 23 int intdat;
0b85893f
KM
24 long longdat;
25 char *strngdat;
26 double dbldat;
27 } errdata;
d3fdcc0c
KM
28
29 errdata.dbldat = 0.0;
30 errdata.intdat = d1;
0b85893f
KM
31 PFLUSH();
32 fputc('\n',stderr);
33 SETRACE();
d3fdcc0c 34 switch ((int)msg) {
0b85893f 35 case ECHR:
492cc5d3 36 fprintf(stderr, "Argument to chr of %D is out of range\n"
0b85893f
KM
37 ,errdata.longdat);
38 return(errdata.longdat);
39 case EHALT:
40 fputs("Call to procedure halt\n",stderr);
41 PCEXIT(0);
42 case ENILPTR:
43 fputs("Pointer value out of legal range\n",stderr);
44 return(0);
45 case EPASTEOF:
46 fprintf(stderr,"%s: Tried to read past end of file\n"
47 ,errdata.strngdat);
48 return(0);
49 case EREADIT:
50 fprintf(stderr,"%s: Attempt to read, but open for writing\n"
51 ,errdata.strngdat);
52 return(0);
53 case EWRITEIT:
54 fprintf(stderr,"%s: Attempt to write, but open for reading\n"
55 ,errdata.strngdat);
56 return(0);
57 case ECLOSE:
58 fprintf(stderr,"%s: Close failed\n",errdata.strngdat);
59 return(0);
60 case ELLIMIT:
61 fprintf(stderr,"%s: Line limit exceeded\n",errdata.strngdat);
62 return(0);
63 case ESQRT:
492cc5d3 64 fprintf(stderr,"Negative argument of %e to sqrt\n"
0b85893f
KM
65 ,errdata.dbldat);
66 return(errdata.dbldat);
67 case EREFINAF:
68 fprintf(stderr,"%s: ",errdata.strngdat);
69 case ENOFILE:
70 fputs("Reference to an inactive file\n",stderr);
71 return(0);
72 case EWRITE:
73 fputs("Could not write to ",stderr);
74 perror(errdata.strngdat);
75 return(0);
76 case EOPEN:
77 fputs("Could not open ",stderr);
78 perror(errdata.strngdat);
79 return(0);
80 case ECREATE:
81 fputs("Could not create ",stderr);
82 perror(errdata.strngdat);
83 return(0);
84 case EREMOVE:
85 fputs("Could not remove ",stderr);
86 perror(errdata.strngdat);
87 return(0);
88 case ESEEK:
89 fputs("Could not reset ",stderr);
90 perror(errdata.strngdat);
91 return(0);
92 case ENAMESIZE:
93 fprintf(stderr,"%s: File name too long\n",errdata.strngdat);
94 return(0);
95 case ELN:
492cc5d3 96 fprintf(stderr,"Non-positive argument of %e to ln\n"
0b85893f
KM
97 ,errdata.dbldat);
98 return(errdata.dbldat);
99 case EBADINUM:
100 fprintf(stderr,"%s: Bad data found on integer read\n"
101 ,errdata.strngdat);
102 return(0);
103 case EBADFNUM:
104 fprintf(stderr,"%s: Bad data found on real read\n"
105 ,errdata.strngdat);
106 return(0);
107 case ENUMNTFD:
108 fprintf(stderr,
109 "Unknown name \"%s\" found on enumerated type read\n",
110 errdata.strngdat);
111 return(0);
112 case ENAMRNG:
113 fprintf(stderr,
492cc5d3 114 "Enumerated type value of %D is out of range on output\n",
0b85893f
KM
115 errdata.longdat);
116 return(errdata.longdat);
117 case EFMTSIZE:
c4b18c79 118 fprintf(stderr,"Non-positive format width: %D\n",errdata.longdat);
0b85893f
KM
119 return(0);
120 case EGOTO:
121 fputs("Active frame not found in non-local goto\n", stderr);
122 return(0);
123 case ECASE:
492cc5d3 124 fprintf(stderr,"Label of %D not found in case\n"
0b85893f
KM
125 ,errdata.longdat);
126 return(errdata.longdat);
127 case EOUTOFMEM:
128 fputs("Ran out of memory\n",stderr);
129 return(0);
0b85893f 130 case EARGV:
492cc5d3 131 fprintf(stderr,"Argument to argv of %D is out of range\n"
0b85893f
KM
132 ,errdata.longdat);
133 return(errdata.longdat);
134 case EPACK:
492cc5d3 135 fprintf(stderr,"i = %D: Bad i to pack(a,i,z)\n"
0b85893f
KM
136 ,errdata.longdat);
137 return(errdata.longdat);
138 case EUNPACK:
492cc5d3 139 fprintf(stderr,"i = %D: Bad i to unpack(z,a,i)\n"
0b85893f
KM
140 ,errdata.longdat);
141 return(errdata.longdat);
142 case ERANGE:
492cc5d3 143 fprintf(stderr,"Value of %D is out of range\n",errdata.longdat);
0b85893f
KM
144 return(errdata.longdat);
145 case ESUBSC:
492cc5d3 146 fprintf(stderr,"Subscript value of %D is out of range\n"
0b85893f
KM
147 ,errdata.longdat);
148 return(errdata.longdat);
149 case EASRT:
150 fprintf(stderr,"Assertion failed: %s\n",errdata.strngdat);
151 return(0);
152 case ESTLIM:
153 fprintf(stderr,
492cc5d3 154 "Statement count limit exceeded, %D statements executed\n",
0b85893f
KM
155 errdata.longdat);
156 return(errdata.longdat);
157 default:
d3fdcc0c 158 fprintf(stderr, msg, d1, d2, d3, d4);
0b85893f
KM
159 return(0);
160 }
161}