1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* enum.c (enum_min, enum_max, enum_min_by, enum_max_by): do not ignore

nil as the first element.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-06-25 06:49:25 +00:00
parent 66e5af96b2
commit 9480c6b720
2 changed files with 24 additions and 17 deletions

View file

@ -1,16 +1,21 @@
Sat Jun 25 15:49:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_min, enum_max, enum_min_by, enum_max_by): do not ignore
nil as the first element.
Sat Jun 25 15:13:54 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/set.rb (Set#==): [ruby-dev:25206] (ported from ruby_1_8 branch)
Sat Jun 25 11:37:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/lib/kconv.rb: remove constants
Iconv_Shift_JIS, Uconv_EUC_JP, Iconv_UTF8
* ext/nkf/lib/kconv.rb: add module functions to Kconv
conv, {eucjp, shiftjis, utf8}?, guess_as_symbol
* ext/nkf/lib/kconv.rb: add instance methods to String
conv, {eucjp, shiftjis, utf8}?
* ext/nkf/lib/kconv.rb: add aliases Kconv.to_* and String#to_*
* ext/nkf/lib/kconv.rb: remove constants
Iconv_Shift_JIS, Uconv_EUC_JP, Iconv_UTF8
* ext/nkf/lib/kconv.rb: add module functions to Kconv
conv, {eucjp, shiftjis, utf8}?, guess_as_symbol
* ext/nkf/lib/kconv.rb: add instance methods to String
conv, {eucjp, shiftjis, utf8}?
* ext/nkf/lib/kconv.rb: add aliases Kconv.to_* and String#to_*
Fri Jun 24 13:17:45 2005 akira yamada <akira@ruby-lang.org>

22
enum.c
View file

@ -607,7 +607,7 @@ min_i(i, memo)
{
VALUE cmp;
if (NIL_P(*memo)) {
if (*memo == Qundef) {
*memo = i;
}
else {
@ -626,7 +626,7 @@ min_ii(i, memo)
{
VALUE cmp;
if (NIL_P(*memo)) {
if (*memo == Qundef) {
*memo = i;
}
else {
@ -657,7 +657,7 @@ static VALUE
enum_min(obj)
VALUE obj;
{
VALUE result = Qnil;
VALUE result = Qundef;
rb_iterate(rb_each, obj, rb_block_given_p() ? min_ii : min_i, (VALUE)&result);
return result;
@ -670,7 +670,7 @@ max_i(i, memo)
{
VALUE cmp;
if (NIL_P(*memo)) {
if (*memo == Qundef) {
*memo = i;
}
else {
@ -689,7 +689,7 @@ max_ii(i, memo)
{
VALUE cmp;
if (NIL_P(*memo)) {
if (*memo == Qundef) {
*memo = i;
}
else {
@ -719,7 +719,7 @@ static VALUE
enum_max(obj)
VALUE obj;
{
VALUE result = Qnil;
VALUE result = Qundef;
rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)&result);
return result;
@ -733,7 +733,7 @@ min_by_i(i, memo)
VALUE v;
v = rb_yield(i);
if (NIL_P(memo[0])) {
if (memo[0] == Qundef) {
memo[0] = v;
memo[1] = i;
}
@ -762,7 +762,8 @@ enum_min_by(obj)
VALUE memo[2];
rb_need_block();
memo[0] = memo[1] = Qnil;
memo[0] = Qundef;
memo[1] = Qnil;
rb_iterate(rb_each, obj, min_by_i, (VALUE)memo);
return memo[1];
}
@ -775,7 +776,7 @@ max_by_i(i, memo)
VALUE v;
v = rb_yield(i);
if (NIL_P(memo[0])) {
if (memo[0] == Qundef) {
memo[0] = v;
memo[1] = i;
}
@ -804,7 +805,8 @@ enum_max_by(obj)
VALUE memo[2];
rb_need_block();
memo[0] = memo[1] = Qnil;
memo[0] = Qundef;
memo[1] = Qnil;
rb_iterate(rb_each, obj, max_by_i, (VALUE)memo);
return memo[1];
}