[bugfix] picrin evaluates exprs in files in order.
This commit is contained in:
parent
808fe32ac0
commit
7ae15246fa
16
tools/main.c
16
tools/main.c
|
@ -159,8 +159,8 @@ int
|
|||
exec_file(pic_state *pic, const char *fname)
|
||||
{
|
||||
FILE *file;
|
||||
bool r;
|
||||
pic_value v;
|
||||
int n, i;
|
||||
pic_value vs;
|
||||
struct pic_proc *proc;
|
||||
|
||||
file = fopen(fname, "r");
|
||||
|
@ -169,12 +169,17 @@ exec_file(pic_state *pic, const char *fname)
|
|||
return 1;
|
||||
}
|
||||
|
||||
r = pic_parse_file(pic, file, &v);
|
||||
if (! r) {
|
||||
n = pic_parse_file(pic, file, &vs);
|
||||
if (n <= 0) {
|
||||
fprintf(stderr, "fatal error: %s broken\n", fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
pic_value v;
|
||||
|
||||
v = pic_car(pic, vs);
|
||||
|
||||
proc = pic_codegen(pic, v);
|
||||
if (proc == NULL) {
|
||||
fputs(pic->errmsg, stderr);
|
||||
|
@ -189,6 +194,9 @@ exec_file(pic_state *pic, const char *fname)
|
|||
return 1;
|
||||
}
|
||||
|
||||
vs = pic_cdr(pic, vs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue