Repository navigation
Expand file tree
/
Copy pathcatch.c
More file actions
executable file
·154 lines (143 loc) · 3.28 KB
/
Copy pathcatch.c
File metadata and controls
executable file
·154 lines (143 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* $Header$ */
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include <em_abs.h>
#include <pc_err.h>
#include <pc_file.h>
/* to make it easier to patch ... */
extern struct file *_curfil;
static struct errm {
int errno;
char *errmes;
} errors[] = {
{ EARRAY, "array bound error"},
{ ERANGE, "range bound error"},
{ ESET, "set bound error"},
{ EIOVFL, "integer overflow"},
{ EFOVFL, "real overflow"},
{ EFUNFL, "real underflow"},
{ EIDIVZ, "divide by 0"},
{ EFDIVZ, "divide by 0.0"},
{ EIUND, "undefined integer"},
{ EFUND, "undefined real"},
{ ECONV, "conversion error"},
{ ESTACK, "stack overflow"},
{ EHEAP, "heap overflow"},
{ EILLINS, "illegal instruction"},
{ EODDZ, "illegal size argument"},
{ ECASE, "case error"},
{ EMEMFLT, "addressing non existent memory"},
{ EBADPTR, "bad pointer used"},
{ EBADPC, "program counter out of range"},
{ EBADLAE, "bad argument of lae"},
{ EBADMON, "bad monitor call"},
{ EBADLIN, "argument if LIN too high"},
{ EBADGTO, "GTO descriptor error"},
{ EARGC, "more args expected" },
{ EEXP, "error in exp" },
{ ELOG, "error in ln" },
{ ESQT, "error in sqrt" },
{ EASS, "assertion failed" },
{ EPACK, "array bound error in pack" },
{ EUNPACK, "array bound error in unpack" },
{ EMOD, "only positive j in 'i mod j'" },
{ EBADF, "file not yet open" },
{ EFREE, "dispose error" },
{ EFUNASS, "function not assigned" },
{ EWIDTH, "illegal field width" },
{ EWRITEF, "not writable" },
{ EREADF, "not readable" },
{ EEOF, "end of file" },
{ EFTRUNC, "truncated" },
{ ERESET, "reset error" },
{ EREWR, "rewrite error" },
{ ECLOSE, "close error" },
{ EREAD, "read error" },
{ EWRITE, "write error" },
{ EDIGIT, "digit expected" },
{ EASCII, "non-ASCII char read" },
{ -1, 0}
};
extern int _pargc;
extern char **_pargv;
extern char ***_penviron;
extern char *_hol0();
extern _trp();
extern _exit();
extern int _write();
_catch(erno) unsigned erno; {
register struct errm *ep = &errors[0];
char *p,*q,*s,**qq;
char buf[20];
unsigned i;
int j = erno;
char *pp[11];
char xbuf[100];
qq = pp;
if (p = FILN)
*qq++ = p;
else
*qq++ = _pargv[0];
while (ep->errno != erno && ep->errmes != 0) ep++;
p = buf;
s = xbuf;
if (i = LINO) {
*qq++ = ", ";
do
*p++ = i % 10 + '0';
while (i /= 10);
while (p > buf) *s++ = *--p;
}
*s++ = ':';
*s++ = ' ';
*s++ = '\0';
*qq++ = xbuf;
if ((erno & ~037) == 0140 && (_curfil->flags&0377)==MAGIC) {
/* file error */
*qq++ = "file ";
*qq++ = _curfil->fname;
*qq++ = ": ";
}
if (ep->errmes) *qq++ = ep->errmes;
else {
*qq++ = "error number ";
*qq++ = s;
p = buf;
if (j < 0) {
j = -j;
*s++ = '-';
}
do
*p++ = j % 10 + '0';
while (j /= 10);
while (p > buf) *s++ = *--p;
*s = 0;
}
*qq++ = "\n";
*qq = 0;
qq = pp;
while (q = *qq++) {
p = q;
while (*p)
p++;
if (_write(2,q,(int)(p-q)) < 0)
;
}
_exit(erno);
error:
_trp(erno);
}