avoid unnecessary copy of context->filename

parent 95fb1fd8
......@@ -158,18 +158,20 @@ partial_hook(struct mrb_parser_state *p)
{
mrbc_context *c = p->cxt;
struct mrbc_args *args = (struct mrbc_args *)c->partial_data;
const char *fn;
if (p->f) fclose(p->f);
if (args->idx >= args->argc) {
p->f = NULL;
return -1;
}
mrbc_filename(p->mrb, c, args->argv[args->idx++]);
p->f = fopen(c->filename, "r");
fn = args->argv[args->idx++];
p->f = fopen(fn, "r");
if (p->f == NULL) {
fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, c->filename);
fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, fn);
return -1;
}
mrbc_filename(p->mrb, c, fn);
p->filename = c->filename;
p->lineno = 1;
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment