diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-05 01:20:20 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-05 01:20:20 +0000 |
commit | 4a429c11e1319b0e13368851454f109217ab5de5 (patch) | |
tree | e2db37bfebe9446a88399aef251d474eb9418295 /enumerator.c | |
parent | ce357ef152869d3c5bfd2e088a31d879daa4ecb6 (diff) | |
download | ruby-4a429c11e1319b0e13368851454f109217ab5de5.tar.gz |
enumerator.c: allow Bignum for with_index
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to
get rid of conversion exception and integer overflow.
[ruby-dev:47131] [Bug #8010]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r-- | enumerator.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/enumerator.c b/enumerator.c index edaa4ad307..bd039d28bc 100644 --- a/enumerator.c +++ b/enumerator.c @@ -460,11 +460,9 @@ enumerator_each(int argc, VALUE *argv, VALUE obj) static VALUE enumerator_with_index_i(VALUE val, VALUE m, int argc, VALUE *argv) { - VALUE idx; VALUE *memo = (VALUE *)m; - - idx = INT2FIX(*memo); - ++*memo; + VALUE idx = *memo; + *memo = rb_int_succ(idx); if (argc <= 1) return rb_yield_values(2, val, idx); @@ -494,7 +492,6 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj) rb_scan_args(argc, argv, "01", &memo); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_size); - memo = NIL_P(memo) ? 0 : (VALUE)NUM2LONG(memo); return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)&memo); } |