diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-11-13 08:22:29 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-11-13 08:22:29 +0000 |
commit | e4d7dbf5a35c8e4ea0de3d50c331c0753a421b32 (patch) | |
tree | 4a78771d1a5d26d2ff798fa7670f56ef7057b76e /array.c | |
parent | 4caab0e0f53d54cf55abb0430352893a1e4f29d9 (diff) |
* signal.c (sighandle): should not re-register sighandler if
POSIX_SIGNAL is defined.
* eval.c (error_print): errat array may be empty.
* parse.y (yylex): float '1_.0' should not be allowed.
* variable.c (var_getter): should care about var as Qfalse
(ruby-bugs#PR199).
* array.c (cmpint): <=> or block for {min,max} may return bignum.
* array.c (sort_1): use rb_compint.
* array.c (sort_2): ditto.
* enum.c (min_ii): ditto.
* enum.c (min_ii): ditto.
* enum.c (max_i): ditto.
* enum.c (max_ii): ditto.
* mkconfig.rb: use String#dump to generate Ruby string literal.
* range.c (range_eql): should override 'eql?'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -933,6 +933,20 @@ rb_ary_reverse_m(ary) return rb_ary_reverse(rb_obj_dup(ary)); } +int +rb_cmpint(cmp) + VALUE cmp; +{ + if (FIXNUM_P(cmp)) return NUM2LONG(cmp); + if (TYPE(cmp) == T_BIGNUM) { + if (RBIGNUM(cmp)->sign) return 1; + return -1; + } + if (rb_funcall(cmp, '>', 1, INT2FIX(0))) return 1; + if (rb_funcall(cmp, '<', 1, INT2FIX(0))) return -1; + return 0; +} + static ID cmp; static int @@ -940,7 +954,7 @@ sort_1(a, b) VALUE *a, *b; { VALUE retval = rb_yield(rb_assoc_new(*a, *b)); - return NUM2INT(retval); + return rb_cmpint(retval); } static int @@ -957,7 +971,7 @@ sort_2(a, b) } retval = rb_funcall(*a, cmp, 1, *b); - return NUM2INT(retval); + return rb_cmpint(retval); } static VALUE |