return v;
case EXIT:
v = eval(ex, x, env);
- exit((int) v.integer);
+ if (ex->disc->exitf)
+ (*ex->disc->exitf) (ex, env, (int)v.integer);
+ else
+ exit((int) v.integer);
/*NOTREACHED*/ v.integer = -1;
return v;
case IF:
return 0;
}
+/*
+ * clear global state of stale pointers
+ */
+
+ void
+ exinit() {
+ memset (&expr, 0, sizeof(Expr_t));
+ }
/*
* compile the expression in [sf]p
*/
typedef int (*Exerror_f) (Expr_t *, Exdisc_t *, int, const char *,
...);
+ typedef void (*Exexit_f) (Expr_t *, Exdisc_t *, int);
typedef struct { /* user defined member type */
Sflong_t number;
/* set value function */
int (*matchf) (Expr_t *, Exnode_t *, const char *, Exnode_t *,
const char *, void *, Exdisc_t *);
+ /* exit function */
+ Exexit_f exitf;
int *types;
void *user;
};
extern char *extype(int);
extern Extype_t exzero(int);
extern char *exopname(int);
+ extern void exinit();
extern char *extypename(Expr_t * p, int);
extern int exisAssign(Exnode_t *);