* push a new input stream and program
*/
-int
-expush(Expr_t* p, const char* name, int line, const char* sp, Sfio_t* fp)
-{
+int expush(Expr_t *p, const char *name, int line, Sfio_t *fp) {
Exinput_t* in;
char* s;
char buf[PATH_MAX];
}
if (!p->input)
p->input = &expr.null;
- if (!(in->bp = in->sp = (char*)sp))
+ in->bp = in->sp = NULL;
+ if ((in->fp = fp))
+ in->close = 0;
+ else if (name)
{
- if ((in->fp = fp))
- in->close = 0;
- else if (name)
+ if (!(s = pathfind(name, p->disc->lib, p->disc->type, buf, sizeof(buf))) || !(in->fp = sfopen(s, "r")))
{
- if (!(s = pathfind(name, p->disc->lib, p->disc->type, buf, sizeof(buf))) || !(in->fp = sfopen(s, "r")))
- {
- exerror("%s: file not found", name);
- in->bp = in->sp = "";
- }
- else
- {
- name = vmstrdup(p->vm, s);
- in->close = 1;
- }
+ exerror("%s: file not found", name);
+ in->bp = in->sp = "";
+ }
+ else
+ {
+ name = vmstrdup(p->vm, s);
+ in->close = 1;
}
}
- else in->fp = 0;
if (!(in->next = p->input)->next)
{
p->errors = 0;
if (!p->input)
return -1;
}
- else if (expush(p, name, line, NULL, fp))
+ else if (expush(p, name, line, fp))
return -1;
else
p->input->unit = line >= 0;
extern char* exnospace(void);
extern Expr_t* exopen(Exdisc_t*);
extern int expop(Expr_t*);
-extern int expush(Expr_t*, const char*, int, const char*, Sfio_t*);
+extern int expush(Expr_t*, const char*, int, Sfio_t*);
extern char* exstash(Sfio_t*, Vmalloc_t*);
extern int extoken_fn(Expr_t*);
extern char* exstring(Expr_t *, char *);
{
if (extoken_fn(ex) != STRING)
exerror("#%s: string argument expected", s);
- else if (!expush(ex, ex_lval.string, 1, NULL, NULL))
+ else if (!expush(ex, ex_lval.string, 1, NULL))
{
setcontext(ex);
goto again;