summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-23 00:51:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-23 00:51:32 +0000
commitf1f0f39e036daa8940996d2957f8756d4db08cdb (patch)
tree6217876c5f588c79c691c943566548c1e10ac61a /array.c
parent2c179216717d75837de7a6ff092fd773670f4d11 (diff)
* hash.c (rb_hash_rehash): replace st_foreach() by its deep
checking counterpart. [ruby-dev:24310] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/array.c b/array.c
index 6045bbea0e..dd1b940acc 100644
--- a/array.c
+++ b/array.c
@@ -97,7 +97,7 @@ rb_ary_frozen_p(ary)
return Qfalse;
}
-static VALUE ary_alloc _((VALUE));
+static VALUE ary_alloc(VALUE);
static VALUE
ary_alloc(klass)
VALUE klass;
@@ -1673,9 +1673,12 @@ sort_1(a, b, data)
struct ary_sort_data *data;
{
VALUE retval = rb_yield_values(2, *a, *b);
+ int n;
ary_sort_check(data);
- return rb_cmpint(retval, *a, *b);
+ n = rb_cmpint(retval, *a, *b);
+ ary_sort_check(data);
+ return n;
}
static int
@@ -1684,11 +1687,12 @@ sort_2(ap, bp, data)
struct ary_sort_data *data;
{
VALUE retval;
- long a = (long)*ap, b = (long)*bp;
+ VALUE a = *ap, b = *bp;
+ int n;
if (FIXNUM_P(a) && FIXNUM_P(b)) {
- if (a > b) return 1;
- if (a < b) return -1;
+ if ((long)a > (long)b) return 1;
+ if ((long)a < (long)b) return -1;
return 0;
}
if (TYPE(a) == T_STRING && TYPE(b) == T_STRING) {
@@ -1697,7 +1701,10 @@ sort_2(ap, bp, data)
retval = rb_funcall(a, id_cmp, 1, b);
ary_sort_check(data);
- return rb_cmpint(retval, a, b);
+ n = rb_cmpint(retval, a, b);
+ ary_sort_check(data);
+
+ return n;
}
static VALUE