aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-14 02:45:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-14 02:45:03 +0000
commit55fba79ee1796e586f8ae8db6d384dc0959cc471 (patch)
tree1bab71f1f5055c44f3db3019983b865f1deca3d3 /variable.c
parent5e3909cb4f6749dde1a1366974a01d5997cbd6cc (diff)
downloadruby-55fba79ee1796e586f8ae8db6d384dc0959cc471.tar.gz
variable.c: $1..$9 in global_variables
* variable.c (rb_f_global_variables): add $1..$9 only if $~ is set. fix the condition removed at r14014. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/variable.c b/variable.c
index 842006ed71..26d9a4b944 100644
--- a/variable.c
+++ b/variable.c
@@ -880,14 +880,16 @@ VALUE
rb_f_global_variables(void)
{
VALUE ary = rb_ary_new();
- char buf[2];
- int i;
rb_id_table_foreach(rb_global_tbl, gvar_i, (void *)ary);
- buf[0] = '$';
- for (i = 1; i <= 9; ++i) {
- buf[1] = (char)(i + '0');
- rb_ary_push(ary, ID2SYM(rb_intern2(buf, 2)));
+ if (!NIL_P(rb_backref_get())) {
+ char buf[2];
+ int i;
+ buf[0] = '$';
+ for (i = 1; i <= 9; ++i) {
+ buf[1] = (char)(i + '0');
+ rb_ary_push(ary, ID2SYM(rb_intern2(buf, 2)));
+ }
}
return ary;
}