mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 17:14:01 +02:00
merge revision(s) 42450: [Backport #8735]
* enumerator.c (lazy_zip_func): fix non-single argument. fix out-of-bound access and pack multiple yielded values. [ruby-core:56383] [Bug #8735] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@42922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
45ce46087a
commit
ba76a79a3e
4 changed files with 27 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Fri Sep 13 00:18:55 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* enumerator.c (lazy_zip_func): fix non-single argument. fix
|
||||||
|
out-of-bound access and pack multiple yielded values.
|
||||||
|
[ruby-core:56383] [Bug #8735]
|
||||||
|
|
||||||
Thu Sep 12 01:44:01 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Sep 12 01:44:01 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (str_gsub): use BEG(0) for whole matched position not
|
* string.c (str_gsub): use BEG(0) for whole matched position not
|
||||||
|
|
|
@ -1661,7 +1661,12 @@ lazy_zip_func(VALUE val, VALUE zip_args, int argc, VALUE *argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
ary = rb_ary_new2(RARRAY_LEN(arg) + 1);
|
ary = rb_ary_new2(RARRAY_LEN(arg) + 1);
|
||||||
rb_ary_push(ary, argv[1]);
|
v = Qnil;
|
||||||
|
if (--argc > 0) {
|
||||||
|
++argv;
|
||||||
|
v = argc > 1 ? rb_ary_new4(argc, argv) : *argv;
|
||||||
|
}
|
||||||
|
rb_ary_push(ary, v);
|
||||||
for (i = 0; i < RARRAY_LEN(arg); i++) {
|
for (i = 0; i < RARRAY_LEN(arg); i++) {
|
||||||
v = rb_rescue2(call_next, RARRAY_PTR(arg)[i], next_stopped, 0,
|
v = rb_rescue2(call_next, RARRAY_PTR(arg)[i], next_stopped, 0,
|
||||||
rb_eStopIteration, (VALUE)0);
|
rb_eStopIteration, (VALUE)0);
|
||||||
|
|
|
@ -292,6 +292,18 @@ class TestLazyEnumerator < Test::Unit::TestCase
|
||||||
assert_equal [[1, 42], [2, :foo]], zip.force
|
assert_equal [[1, 42], [2, :foo]], zip.force
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_zip_nonsingle
|
||||||
|
bug8735 = '[ruby-core:56383] [Bug #8735]'
|
||||||
|
|
||||||
|
obj = Object.new
|
||||||
|
def obj.each
|
||||||
|
yield
|
||||||
|
yield 1, 2
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal(obj.to_enum.zip(obj.to_enum), obj.to_enum.lazy.zip(obj.to_enum).force, bug8735)
|
||||||
|
end
|
||||||
|
|
||||||
def test_take_rewound
|
def test_take_rewound
|
||||||
bug7696 = '[ruby-core:51470]'
|
bug7696 = '[ruby-core:51470]'
|
||||||
e=(1..42).lazy.take(2)
|
e=(1..42).lazy.take(2)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "2.0.0"
|
#define RUBY_VERSION "2.0.0"
|
||||||
#define RUBY_RELEASE_DATE "2013-09-12"
|
#define RUBY_RELEASE_DATE "2013-09-13"
|
||||||
#define RUBY_PATCHLEVEL 304
|
#define RUBY_PATCHLEVEL 305
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2013
|
#define RUBY_RELEASE_YEAR 2013
|
||||||
#define RUBY_RELEASE_MONTH 9
|
#define RUBY_RELEASE_MONTH 9
|
||||||
#define RUBY_RELEASE_DAY 12
|
#define RUBY_RELEASE_DAY 13
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue