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

ruby-changes:39951

From: nagachika <ko1@a...>
Date: Mon, 5 Oct 2015 03:42:39 +0900 (JST)
Subject: [ruby-changes:39951] nagachika:r52032 (ruby_2_2): merge revision(s) 52026: [Backport #11471]

nagachika	2015-10-05 03:42:19 +0900 (Mon, 05 Oct 2015)

  New Revision: 52032

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

  Log:
    merge revision(s) 52026: [Backport #11471]
    
    * enum.c (nmin_filter): Fix limit value.
      patch by Helder Pereira.
      [Bug #11471] [ruby-core:70477]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/enum.c
    branches/ruby_2_2/test/ruby/test_enum.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 52031)
+++ ruby_2_2/ChangeLog	(revision 52032)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Mon Oct  5 03:29:23 2015  Tanaka Akira  <akr@f...>
+
+	* enum.c (nmin_filter): Fix limit value.
+	  patch by Helder Pereira.
+	  [Bug #11471] [ruby-core:70477]
+
 Wed Sep 30 03:44:36 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rss/rss.rb (Time#w3cdtf): fix zero-trimmed width of fraction
Index: ruby_2_2/enum.c
===================================================================
--- ruby_2_2/enum.c	(revision 52031)
+++ ruby_2_2/enum.c	(revision 52032)
@@ -1148,6 +1148,7 @@ nmin_filter(struct nmin_data *data) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1148
     long numelts;
 
     long left, right;
+    long store_index;
 
     long i, j;
 
@@ -1173,7 +1174,6 @@ nmin_filter(struct nmin_data *data) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1174
 
     while (1) {
 	long pivot_index = left + (right-left)/2;
-	long store_index;
 	long num_pivots = 1;
 
 	SWAP(pivot_index, right);
@@ -1217,9 +1217,9 @@ nmin_filter(struct nmin_data *data) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1217
 #undef GETPTR
 #undef SWAP
 
+    data->limit = RARRAY_PTR(data->buf)[store_index*eltsize];
     data->curlen = data->n;
     rb_ary_resize(data->buf, data->n * eltsize);
-    data->limit = RARRAY_PTR(data->buf)[(data->n-1)*eltsize];
 }
 
 static VALUE
@@ -1239,7 +1239,7 @@ nmin_i(VALUE i, VALUE *_data, int argc, https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1239
         int c = data->cmpfunc(&cmpv, &data->limit, data);
         if (data->rev)
             c = -c;
-        if (c > 0)
+        if (c >= 0)
             return Qnil;
     }
 
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 52031)
+++ ruby_2_2/version.h	(revision 52032)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.4"
-#define RUBY_RELEASE_DATE "2015-09-30"
-#define RUBY_PATCHLEVEL 178
+#define RUBY_RELEASE_DATE "2015-10-05"
+#define RUBY_PATCHLEVEL 179
 
 #define RUBY_RELEASE_YEAR 2015
-#define RUBY_RELEASE_MONTH 9
-#define RUBY_RELEASE_DAY 30
+#define RUBY_RELEASE_MONTH 10
+#define RUBY_RELEASE_DAY 5
 
 #include "ruby/version.h"
 
Index: ruby_2_2/test/ruby/test_enum.rb
===================================================================
--- ruby_2_2/test/ruby/test_enum.rb	(revision 52031)
+++ ruby_2_2/test/ruby/test_enum.rb	(revision 52032)
@@ -251,6 +251,8 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_enum.rb#L251
     assert_equal(%w[albatross dog], ary.min(2))
     assert_equal(%w[dog horse],
                  ary.min(2) {|a,b| a.length <=> b.length })
+    assert_equal([13, 14], [20, 32, 32, 21, 30, 25, 29, 13, 14].min(2))
+    assert_equal([2, 4, 6, 7], [2, 4, 8, 6, 7].min(4))
   end
 
   def test_max
@@ -265,6 +267,7 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_enum.rb#L267
     assert_equal(%w[horse dog], ary.max(2))
     assert_equal(%w[albatross horse],
                  ary.max(2) {|a,b| a.length <=> b.length })
+    assert_equal([3, 2], [0, 0, 0, 0, 0, 0, 1, 3, 2].max(2))
   end
 
   def test_minmax
@@ -286,6 +289,7 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_enum.rb#L289
     assert_equal("dog", a.min_by {|x| x.length })
     assert_equal(3, [2,3,1].min_by {|x| -x })
     assert_equal(%w[dog horse], a.min_by(2) {|x| x.length })
+    assert_equal([13, 14], [20, 32, 32, 21, 30, 25, 29, 13, 14].min_by(2) {|x| x})
   end
 
   def test_max_by
@@ -296,6 +300,7 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_enum.rb#L300
     assert_equal("albatross", a.max_by {|x| x.length })
     assert_equal(1, [2,3,1].max_by {|x| -x })
     assert_equal(%w[albatross horse], a.max_by(2) {|x| x.length })
+    assert_equal([3, 2], [0, 0, 0, 0, 0, 0, 1, 3, 2].max_by(2) {|x| x})
   end
 
   def test_minmax_by

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r52026


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

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