ruby-changes:29597
From: usa <ko1@a...>
Date: Wed, 26 Jun 2013 16:51:16 +0900 (JST)
Subject: [ruby-changes:29597] usa:r41649 (ruby_1_9_3): merge revision(s) 40525,40526,40528,40530: [Backport #8345]
usa 2013-06-26 16:51:04 +0900 (Wed, 26 Jun 2013) New Revision: 41649 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41649 Log: merge revision(s) 40525,40526,40528,40530: [Backport #8345] proc.c: remove unnecessary static function * proc.c (proc_lambda): remove and use rb_block_lambda directly instead. * include/ruby/intern.h (rb_block_lambda): add declaration instead of deprecated rb_f_lambda. * proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345] * vm.c (Init_VM): define proc and lambda on the frozen core object. * defs/id.def (predefined): add "idProc". * proc.c (mnew, mproc, mlambda): use predefined IDs. * vm.c (Init_VM): ditto. Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/id.c branches/ruby_1_9_3/include/ruby/intern.h branches/ruby_1_9_3/proc.c branches/ruby_1_9_3/template/id.h.tmpl branches/ruby_1_9_3/test/ruby/test_proc.rb branches/ruby_1_9_3/version.h branches/ruby_1_9_3/vm.c Index: ruby_1_9_3/include/ruby/intern.h =================================================================== --- ruby_1_9_3/include/ruby/intern.h (revision 41648) +++ ruby_1_9_3/include/ruby/intern.h (revision 41649) @@ -350,7 +350,7 @@ VALUE rb_require_safe(VALUE, int); https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/include/ruby/intern.h#L350 void rb_obj_call_init(VALUE, int, VALUE*); VALUE rb_class_new_instance(int, VALUE*, VALUE); VALUE rb_block_proc(void); -VALUE rb_f_lambda(void); +VALUE rb_block_lambda(void); VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE); VALUE rb_obj_is_proc(VALUE); VALUE rb_proc_call(VALUE, VALUE); Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 41648) +++ ruby_1_9_3/ChangeLog (revision 41649) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Wed Jun 26 16:36:39 2013 Nobuyoshi Nakada <nobu@r...> + + * defs/id.def (predefined): add "idProc". + + * proc.c (mnew, mproc, mlambda): use predefined IDs. + + * vm.c (Init_VM): ditto. + +Wed Jun 26 16:36:39 2013 Nobuyoshi Nakada <nobu@r...> + + * include/ruby/intern.h (rb_block_lambda): add declaration instead of + deprecated rb_f_lambda. + Wed Jun 26 16:31:49 2013 Shugo Maeda <shugo@r...> * lib/net/imap.rb (capability_response): should ignore trailing Index: ruby_1_9_3/proc.c =================================================================== --- ruby_1_9_3/proc.c (revision 41648) +++ ruby_1_9_3/proc.c (revision 41649) @@ -465,6 +465,14 @@ rb_block_proc(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/proc.c#L465 return proc_new(rb_cProc, FALSE); } +/* + * call-seq: + * lambda { |...| block } -> a_proc + * + * Equivalent to <code>Proc.new</code>, except the resulting Proc objects + * check the number of parameters passed when called. + */ + VALUE rb_block_lambda(void) { @@ -478,20 +486,6 @@ rb_f_lambda(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/proc.c#L486 return rb_block_lambda(); } -/* - * call-seq: - * lambda { |...| block } -> a_proc - * - * Equivalent to <code>Proc.new</code>, except the resulting Proc objects - * check the number of parameters passed when called. - */ - -static VALUE -proc_lambda(void) -{ - return rb_block_lambda(); -} - /* Document-method: === * * call-seq: @@ -1798,13 +1792,13 @@ method_inspect(VALUE method) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/proc.c#L1792 static VALUE mproc(VALUE method) { - return rb_funcall(Qnil, rb_intern("proc"), 0); + return rb_funcall2(rb_mRubyVMFrozenCore, idProc, 0, 0); } static VALUE mlambda(VALUE method) { - return rb_funcall(Qnil, rb_intern("lambda"), 0); + return rb_funcall(rb_mRubyVMFrozenCore, idLambda, 0, 0); } static VALUE @@ -2151,7 +2145,7 @@ Init_Proc(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/proc.c#L2145 /* utility functions */ rb_define_global_function("proc", rb_block_proc, 0); - rb_define_global_function("lambda", proc_lambda, 0); + rb_define_global_function("lambda", rb_block_lambda, 0); /* Method */ rb_cMethod = rb_define_class("Method", rb_cObject); Index: ruby_1_9_3/id.c =================================================================== --- ruby_1_9_3/id.c (revision 41648) +++ ruby_1_9_3/id.c (revision 41649) @@ -35,6 +35,7 @@ Init_id(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/id.c#L35 REGISTER_SYMID(idEach, "each"); REGISTER_SYMID(idLength, "length"); REGISTER_SYMID(idSize, "size"); + REGISTER_SYMID(idProc, "proc"); REGISTER_SYMID(idLambda, "lambda"); REGISTER_SYMID(idIntern, "intern"); REGISTER_SYMID(idGets, "gets"); Index: ruby_1_9_3/vm.c =================================================================== --- ruby_1_9_3/vm.c (revision 41648) +++ ruby_1_9_3/vm.c (revision 41649) @@ -2109,6 +2109,8 @@ Init_VM(void) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/vm.c#L2109 rb_define_method_id(klass, id_core_define_method, m_core_define_method, 3); rb_define_method_id(klass, id_core_define_singleton_method, m_core_define_singleton_method, 3); rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 1); + rb_define_method_id(klass, idProc, rb_block_proc, 0); + rb_define_method_id(klass, idLambda, rb_block_lambda, 0); rb_obj_freeze(fcore); rb_gc_register_mark_object(fcore); rb_mRubyVMFrozenCore = fcore; Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 41648) +++ ruby_1_9_3/version.h (revision 41649) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 440 +#define RUBY_PATCHLEVEL 441 #define RUBY_RELEASE_DATE "2013-06-26" #define RUBY_RELEASE_YEAR 2013 Index: ruby_1_9_3/test/ruby/test_proc.rb =================================================================== --- ruby_1_9_3/test/ruby/test_proc.rb (revision 41648) +++ ruby_1_9_3/test/ruby/test_proc.rb (revision 41649) @@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_proc.rb#L1 require 'test/unit' +require_relative 'envutil' class TestProc < Test::Unit::TestCase def setup @@ -818,4 +819,14 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_proc.rb#L819 assert_equal('zot', o.method(:foo).to_proc.() {'zot'}, bug3792) } end + + def test_overriden_lambda + bug8345 = '[ruby-core:54687] [Bug #8345]' + assert_normal_exit('def lambda; end; method(:puts).to_proc', bug8345) + end + + def test_overriden_proc + bug8345 = '[ruby-core:54688] [Bug #8345]' + assert_normal_exit('def proc; end; ->{}.curry', bug8345) + end end Index: ruby_1_9_3/template/id.h.tmpl =================================================================== --- ruby_1_9_3/template/id.h.tmpl (revision 41648) +++ ruby_1_9_3/template/id.h.tmpl (revision 41649) @@ -98,6 +98,7 @@ enum ruby_method_ids { https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/template/id.h.tmpl#L98 tGets, tSucc, tEach, + tProc, tLambda, tSend, t__send__, @@ -120,6 +121,7 @@ enum ruby_method_ids { https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/template/id.h.tmpl#L121 TOKEN2ID(Gets), TOKEN2ID(Succ), TOKEN2ID(Each), + TOKEN2ID(Proc), TOKEN2ID(Lambda), TOKEN2ID(Send), TOKEN2ID(__send__), Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r40525-40526,40528,40530 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/