[前][次][番号順一覧][スレッド一覧]

ruby-changes:25125

From: nobu <ko1@a...>
Date: Sun, 14 Oct 2012 12:31:06 +0900 (JST)
Subject: [ruby-changes:25125] nobu:r37177 (trunk): ruby.c: passing block

nobu	2012-10-14 12:30:50 +0900 (Sun, 14 Oct 2012)

  New Revision: 37177

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37177

  Log:
    ruby.c: passing block
    
    * ruby.c (rb_f_sub, rb_f_gsub): pass the given block.
      [ruby-core:47967] [Bug #7157]

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c
    trunk/test/ruby/test_rubyoptions.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37176)
+++ ChangeLog	(revision 37177)
@@ -1,3 +1,8 @@
+Sun Oct 14 12:30:44 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* regparse.c (parse_char_class): should match with a hyphen after a
Index: ruby.c
===================================================================
--- ruby.c	(revision 37176)
+++ ruby.c	(revision 37177)
@@ -1186,7 +1186,7 @@
 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 @@
 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 @@
 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 @@
 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;
 }
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 37176)
+++ test/ruby/test_rubyoptions.rb	(revision 37177)
@@ -578,4 +578,14 @@
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]