mruby.c: specify file names for libraries set by `-r`; fix
MODIFY
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
@@ -272,7 +272,6 @@ main(int argc, char **argv)
mrb_value ARGV;
mrbc_context *c;
mrb_value v;
- mrb_sym zero_sym;
if (mrb == NULL) {
fprintf(stderr, "%s: Invalid mrb_state, exiting mruby\n", *argv);
@@ -304,17 +303,14 @@ main(int argc, char **argv)
c->no_exec = TRUE;
/* Set $0 */
- zero_sym = mrb_intern_lit(mrb, "$0");
- if (args.rfp) {
const char *cmdline;
+ if (args.rfp) {
cmdline = args.cmdline ? args.cmdline : "-";
- mrbc_filename(mrb, c, cmdline);
- mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
}
else {
- mrbc_filename(mrb, c, "-e");
- mrb_gv_set(mrb, zero_sym, mrb_str_new_lit(mrb, "-e"));
+ cmdline = "-e";
}
+ mrb_gv_set(mrb, mrb_intern_lit(mrb, "$0"), mrb_str_new_cstr(mrb, cmdline));
/* Load libraries */
for (i = 0; i < args.libc; i++) {
@@ -326,6 +322,7 @@ main(int argc, char **argv)
cleanup(mrb, &args);
return EXIT_FAILURE;
}
+ mrbc_filename(mrb, c, args.libv[i]);
if (args.mrbfile) {
v = mrb_load_irep_file_cxt(mrb, lfp, c);
}
@@ -339,6 +336,9 @@ main(int argc, char **argv)
mrbc_cleanup_local_variables(mrb, c);
}
+ /* set program file name */
+ mrbc_filename(mrb, c, cmdline);
+
/* Load program */
if (args.mrbfile) {
v = mrb_load_irep_file_cxt(mrb, args.rfp, c);

mruby.c: specify file names for libraries set by `-r`; fix #5427