mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
merge revision(s) 23624:
* enum.c (first_i): Enumerator#first should consume only what is needed. a patch from Marc-Andre Lafortune. [ruby-core:23661] * enum.c (take_i): ditto. * enum.c (enum_first): call to_int once for an argument. a patch from Marc-Andre Lafortune. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@24272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f815568fc6
commit
151087a834
3 changed files with 23 additions and 9 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Sat Jul 25 21:26:18 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* enum.c (first_i): Enumerator#first should consume only what is
|
||||||
|
needed. a patch from Marc-Andre Lafortune. [ruby-core:23661]
|
||||||
|
|
||||||
|
* enum.c (take_i): ditto.
|
||||||
|
|
||||||
|
* enum.c (enum_first): call to_int once for an argument. a patch
|
||||||
|
from Marc-Andre Lafortune.
|
||||||
|
|
||||||
Fri Jul 24 17:19:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri Jul 24 17:19:40 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* lib/cgi.rb (HTTP_STATUS): typo fixed. [ruby-dev:38538]
|
* lib/cgi.rb (HTTP_STATUS): typo fixed. [ruby-dev:38538]
|
||||||
|
|
14
enum.c
14
enum.c
|
@ -667,11 +667,11 @@ first_i(i, ary)
|
||||||
else {
|
else {
|
||||||
long n = NUM2LONG(ary[0]);
|
long n = NUM2LONG(ary[0]);
|
||||||
|
|
||||||
|
rb_ary_push(ary[1], i);
|
||||||
|
n--;
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
rb_iter_break();
|
rb_iter_break();
|
||||||
}
|
}
|
||||||
rb_ary_push(ary[1], i);
|
|
||||||
n--;
|
|
||||||
ary[0] = INT2NUM(n);
|
ary[0] = INT2NUM(n);
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
@ -700,9 +700,12 @@ enum_first(argc, argv, obj)
|
||||||
ary[0] = ary[1] = Qnil;
|
ary[0] = ary[1] = Qnil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
long len;
|
||||||
rb_scan_args(argc, argv, "01", &n);
|
rb_scan_args(argc, argv, "01", &n);
|
||||||
ary[0] = n;
|
len = NUM2LONG(n);
|
||||||
ary[1] = rb_ary_new2(NUM2LONG(n));
|
if (len == 0) return rb_ary_new2(0);
|
||||||
|
ary[0] = INT2NUM(len);
|
||||||
|
ary[1] = rb_ary_new2(len);
|
||||||
}
|
}
|
||||||
rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)ary);
|
rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)ary);
|
||||||
|
|
||||||
|
@ -1609,8 +1612,8 @@ take_i(i, arg)
|
||||||
VALUE i;
|
VALUE i;
|
||||||
VALUE *arg;
|
VALUE *arg;
|
||||||
{
|
{
|
||||||
if (arg[1]-- == 0) rb_iter_break();
|
|
||||||
rb_ary_push(arg[0], i);
|
rb_ary_push(arg[0], i);
|
||||||
|
if (--arg[1] == 0) rb_iter_break();
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1637,6 +1640,7 @@ enum_take(obj, n)
|
||||||
rb_raise(rb_eArgError, "attempt to take negative size");
|
rb_raise(rb_eArgError, "attempt to take negative size");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len == 0) return rb_ary_new2(0);
|
||||||
args[1] = len;
|
args[1] = len;
|
||||||
args[0] = rb_ary_new();
|
args[0] = rb_ary_new();
|
||||||
rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)args);
|
rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)args);
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#define RUBY_VERSION "1.8.7"
|
#define RUBY_VERSION "1.8.7"
|
||||||
#define RUBY_RELEASE_DATE "2009-07-24"
|
#define RUBY_RELEASE_DATE "2009-07-25"
|
||||||
#define RUBY_VERSION_CODE 187
|
#define RUBY_VERSION_CODE 187
|
||||||
#define RUBY_RELEASE_CODE 20090724
|
#define RUBY_RELEASE_CODE 20090725
|
||||||
#define RUBY_PATCHLEVEL 189
|
#define RUBY_PATCHLEVEL 190
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
#define RUBY_VERSION_MINOR 8
|
#define RUBY_VERSION_MINOR 8
|
||||||
#define RUBY_VERSION_TEENY 7
|
#define RUBY_VERSION_TEENY 7
|
||||||
#define RUBY_RELEASE_YEAR 2009
|
#define RUBY_RELEASE_YEAR 2009
|
||||||
#define RUBY_RELEASE_MONTH 7
|
#define RUBY_RELEASE_MONTH 7
|
||||||
#define RUBY_RELEASE_DAY 24
|
#define RUBY_RELEASE_DAY 25
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue