diff options
author | Koichi Sasada <ko1@atdot.net> | 2022-07-29 16:02:10 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2022-08-01 17:48:05 +0900 |
commit | 5bbba76489628f4509495ebf4ba0a7aad4c0b560 (patch) | |
tree | 10cdc8fb1474b43122a132501feb05f4032ec271 /ext/-test- | |
parent | 1520936aa760e6b2747d31c37854f22a63591667 (diff) | |
download | ruby-5bbba76489628f4509495ebf4ba0a7aad4c0b560.tar.gz |
respect current frame of `rb_eval_string`
`self` is nearest Ruby method's `self`.
If there is no ruby frame, use toplevel `self` (`main`).
https://bugs.ruby-lang.org/issues/18780
Diffstat (limited to 'ext/-test-')
-rw-r--r-- | ext/-test-/eval/eval.c | 13 | ||||
-rw-r--r-- | ext/-test-/eval/extconf.rb | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/ext/-test-/eval/eval.c b/ext/-test-/eval/eval.c new file mode 100644 index 0000000000..983468fc34 --- /dev/null +++ b/ext/-test-/eval/eval.c @@ -0,0 +1,13 @@ +#include "ruby/ruby.h" + +static VALUE +eval_string(VALUE self, VALUE str) +{ + return rb_eval_string(StringValueCStr(str)); +} + +void +Init_eval(void) +{ + rb_define_global_function("rb_eval_string", eval_string, 1); +} diff --git a/ext/-test-/eval/extconf.rb b/ext/-test-/eval/extconf.rb new file mode 100644 index 0000000000..cdbf6a8597 --- /dev/null +++ b/ext/-test-/eval/extconf.rb @@ -0,0 +1,2 @@ +require 'mkmf' +create_makefile('-test-/eval') |