-
Notifications
You must be signed in to change notification settings - Fork 4
/
error.c
41 lines (39 loc) · 941 Bytes
/
error.c
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
/*
* module : error.c
* version : 1.3
* date : 10/11/24
*/
#include "globals.h"
/*
* print a runtime error to stderr and abort the execution of current program.
*/
void execerror(pEnv env, char *message, char *op)
{
int leng = 0;
char *ptr, *str;
#ifdef COMPILER
Entry ent;
if (env->compiling > 0) {
leng = lookup(env, op); /* locate in symbol table */
if (leng < tablesize())
op = nickname(leng);
ent = vec_at(env->symtab, leng);
ent.flags |= IS_USED;
vec_at(env->symtab, leng) = ent;
printstack(env);
fprintf(env->outfp, "%s_(env);\n", op);
return;
}
#endif
if ((ptr = strrchr(op, '/')) != 0)
ptr++;
else
ptr = op;
if ((str = strrchr(ptr, '.')) != 0 && str[1] == 'c')
leng = str - ptr;
else
leng = strlen(ptr);
fflush(stdout);
fprintf(stderr, "run time error: %s needed for %.*s\n", message, leng, ptr);
abortexecution_(ABORT_RETRY);
} /* LCOV_EXCL_LINE */