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): 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
This commit is contained in:
nobu 2005-06-25 06:49:40 +00:00
parent 19c96dfff9
commit 47679bcf0a
2 changed files with 10 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Sat Jun 25 15:49:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_min, enum_max): do not ignore nil as the first element.
Sat Jun 25 14:40:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> Sat Jun 25 14:40:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/sdbm/init.c (fsdbm_select): SDBM#select had returned the array * ext/sdbm/init.c (fsdbm_select): SDBM#select had returned the array

12
enum.c
View file

@ -607,7 +607,7 @@ min_i(i, memo)
{ {
VALUE cmp; VALUE cmp;
if (NIL_P(*memo)) { if (*memo == Qundef) {
*memo = i; *memo = i;
} }
else { else {
@ -626,7 +626,7 @@ min_ii(i, memo)
{ {
VALUE cmp; VALUE cmp;
if (NIL_P(*memo)) { if (*memo == Qundef) {
*memo = i; *memo = i;
} }
else { else {
@ -657,7 +657,7 @@ static VALUE
enum_min(obj) enum_min(obj)
VALUE obj; VALUE obj;
{ {
VALUE result = Qnil; VALUE result = Qundef;
rb_iterate(rb_each, obj, rb_block_given_p() ? min_ii : min_i, (VALUE)&result); rb_iterate(rb_each, obj, rb_block_given_p() ? min_ii : min_i, (VALUE)&result);
return result; return result;
@ -684,7 +684,7 @@ max_i(i, memo)
{ {
VALUE cmp; VALUE cmp;
if (NIL_P(*memo)) { if (*memo == Qundef) {
*memo = i; *memo = i;
} }
else { else {
@ -703,7 +703,7 @@ max_ii(i, memo)
{ {
VALUE cmp; VALUE cmp;
if (NIL_P(*memo)) { if (*memo == Qundef) {
*memo = i; *memo = i;
} }
else { else {
@ -733,7 +733,7 @@ static VALUE
enum_max(obj) enum_max(obj)
VALUE obj; VALUE obj;
{ {
VALUE result = Qnil; VALUE result = Qundef;
rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)&result); rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)&result);
return result; return result;