summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-mruby/tools
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-09-10 18:12:38 +0900
committerGitHub <[email protected]>2020-09-10 18:12:38 +0900
commitc27e45193177b6e4d09d526a248af63c0961035a (patch)
tree863c5082109295c880311b2abe1eefc4c748dc4d /mrbgems/mruby-bin-mruby/tools
parentc345fe432171cc2b90b614a0b44305b218090de6 (diff)
parent9840e5352b2abf96235068f0e9d08f14b1d333cf (diff)
downloadmruby-c27e45193177b6e4d09d526a248af63c0961035a.tar.gz
mruby-c27e45193177b6e4d09d526a248af63c0961035a.zip
Merge pull request #4933 from dearblue/variables
Fix take over file scope variables with `mruby` and `mirb` command
Diffstat (limited to 'mrbgems/mruby-bin-mruby/tools')
-rw-r--r--mrbgems/mruby-bin-mruby/tools/mruby/mruby.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c b/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
index e5c8f3466..793245875 100644
--- a/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
+++ b/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
@@ -10,6 +10,7 @@
#include <mruby/compile.h>
#include <mruby/dump.h>
#include <mruby/variable.h>
+#include <mruby/proc.h>
struct _args {
FILE *rfp;
@@ -307,6 +308,7 @@ main(int argc, char **argv)
/* Load libraries */
for (i = 0; i < args.libc; i++) {
+ struct REnv *e;
FILE *lfp = fopen(args.libv[i], args.mrbfile ? "rb" : "r");
if (lfp == NULL) {
fprintf(stderr, "%s: Cannot open library file: %s\n", *argv, args.libv[i]);
@@ -321,6 +323,10 @@ main(int argc, char **argv)
v = mrb_load_file_cxt(mrb, lfp, c);
}
fclose(lfp);
+ e = mrb->c->cibase->env;
+ mrb->c->cibase->env = NULL;
+ mrb_env_unshare(mrb, e);
+ mrbc_cleanup_local_variables(mrb, c);
}
/* Load program */