mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby.c: passing block
* ruby.c (rb_f_sub, rb_f_gsub): pass the given block. [ruby-core:47967] [Bug #7157] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
be3a6b8c40
commit
9e02550b21
3 changed files with 19 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Oct 14 12:30:44 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (rb_f_sub, rb_f_gsub): pass the given block.
|
||||
[ruby-core:47967] [Bug #7157]
|
||||
|
||||
Sat Oct 13 23:15:39 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* regparse.c (parse_char_class): should match with a hyphen after a
|
||||
|
|
8
ruby.c
8
ruby.c
|
@ -1186,7 +1186,7 @@ uscore_get(void)
|
|||
static VALUE
|
||||
rb_f_sub(int argc, VALUE *argv)
|
||||
{
|
||||
VALUE str = rb_funcall3(uscore_get(), rb_intern("sub"), argc, argv);
|
||||
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("sub"), argc, argv);
|
||||
rb_lastline_set(str);
|
||||
return str;
|
||||
}
|
||||
|
@ -1205,7 +1205,7 @@ rb_f_sub(int argc, VALUE *argv)
|
|||
static VALUE
|
||||
rb_f_gsub(int argc, VALUE *argv)
|
||||
{
|
||||
VALUE str = rb_funcall3(uscore_get(), rb_intern("gsub"), argc, argv);
|
||||
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("gsub"), argc, argv);
|
||||
rb_lastline_set(str);
|
||||
return str;
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ rb_f_gsub(int argc, VALUE *argv)
|
|||
static VALUE
|
||||
rb_f_chop(void)
|
||||
{
|
||||
VALUE str = rb_funcall3(uscore_get(), rb_intern("chop"), 0, 0);
|
||||
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chop"), 0, 0);
|
||||
rb_lastline_set(str);
|
||||
return str;
|
||||
}
|
||||
|
@ -1243,7 +1243,7 @@ rb_f_chop(void)
|
|||
static VALUE
|
||||
rb_f_chomp(int argc, VALUE *argv)
|
||||
{
|
||||
VALUE str = rb_funcall3(uscore_get(), rb_intern("chomp"), argc, argv);
|
||||
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chomp"), argc, argv);
|
||||
rb_lastline_set(str);
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -578,4 +578,14 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
feature2408 = '[ruby-core:26925]'
|
||||
assert_in_out_err(%w[.], "", [], /Is a directory -- \./, feature2408)
|
||||
end
|
||||
|
||||
def test_pflag_gsub
|
||||
bug7157 = '[ruby-core:47967]'
|
||||
assert_in_out_err(['-p', '-e', 'gsub(/t.*/){"TEST"}'], %[test], %w[TEST], [], bug7157)
|
||||
end
|
||||
|
||||
def test_pflag_sub
|
||||
bug7157 = '[ruby-core:47967]'
|
||||
assert_in_out_err(['-p', '-e', 'sub(/t.*/){"TEST"}'], %[test], %w[TEST], [], bug7157)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue