From 7422ccdd9e2fb2b28844879d5117d8fdc000c944 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 13 Nov 2001 08:19:52 +0000 Subject: * signal.c (sighandle): should not re-register sighandler if POSIX_SIGNAL is defined. * eval.c (error_print): errat array may be empty. * eval.c (rb_eval_cmd): should not upgrade safe level unless explicitly specified by argument newly added. * signal.c (sig_trap): should not allow tainted trap closure. * variable.c (rb_f_trace_var): should not allow trace_var on safe level higher than 3. * variable.c (rb_f_trace_var): should not allow tainted trace closure. * gc.c: do not use static stack until system stack overflows. * eval.c (eval): should call Exception#exception instead of calling rb_exc_new3() directly. * error.c (exc_exception): set "mesg" directly to the clone. it might be better to set mesg via some method for flexibility. * variable.c (cvar_override_check): should print original module name, if 'a' is T_ICLASS. * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 79131901e3..0dfa3aef40 100644 --- a/array.c +++ b/array.c @@ -1004,12 +1004,26 @@ rb_ary_reverse_m(ary) return rb_ary_reverse(rb_ary_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 int 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 @@ -1026,7 +1040,7 @@ sort_2(a, b) } retval = rb_funcall(*a, cmp, 1, *b); - return NUM2INT(retval); + return rb_cmpint(retval); } static VALUE -- cgit v1.2.3