From 47679bcf0aea586af1aa3a8bee0c6356c2993f5a Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 25 Jun 2005 06:49:40 +0000 Subject: [PATCH] * enum.c (enum_min, enum_max): do not ignore nil as the first element. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ enum.c | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d94df3eba..12293db362 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jun 25 15:49:18 2005 Nobuyoshi Nakada + + * enum.c (enum_min, enum_max): do not ignore nil as the first element. + Sat Jun 25 14:40:17 2005 Hirokazu Yamamoto * ext/sdbm/init.c (fsdbm_select): SDBM#select had returned the array diff --git a/enum.c b/enum.c index ca52b6f566..102257fa76 100644 --- a/enum.c +++ b/enum.c @@ -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; @@ -684,7 +684,7 @@ max_i(i, memo) { VALUE cmp; - if (NIL_P(*memo)) { + if (*memo == Qundef) { *memo = i; } else { @@ -703,7 +703,7 @@ max_ii(i, memo) { VALUE cmp; - if (NIL_P(*memo)) { + if (*memo == Qundef) { *memo = i; } else { @@ -733,7 +733,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;