summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-13 03:55:44 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-13 03:55:44 +0000
commitb3ecbfaa01e7c75bfea9c895bb7476c58e998131 (patch)
tree1b23f1e6c0b8291136e64917835310a6cbde1fbc /enum.c
parenta2020f907a942f09c651b1006151c932cdf7e77e (diff)
* eval.c (svalue_to_avalue): v may be Qundef. This fix was
suggested by Guy Decoux. * hash.c (rb_hash_s_create): use rb_hash_aset() instead of calling st_insert() directly, to dup&freeze string keys. * parse.y (yylex): proper error message for "@@0". * parse.y (yylex): paren to parse_string() must be zero for unparenthesized strings. * parse.y (str_extend): broken string when unterminated "#{". * enum.c (enum_sort_by): had a bug in 1 element enumeration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/enum.c b/enum.c
index 321d084..29f507c 100644
--- a/enum.c
+++ b/enum.c
@@ -280,8 +280,9 @@ enum_sort_by(obj)
ary = rb_ary_new2((TYPE(obj) == T_ARRAY) ? RARRAY(obj)->len : 2000);
rb_iterate(rb_each, obj, sort_by_i, ary);
- if (RARRAY(ary)->len <= 1) return ary;
- qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp);
+ if (RARRAY(obj)->len > 1) {
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp);
+ }
for (i=0; i<RARRAY(ary)->len; i++) {
VALUE e = RARRAY(ary)->ptr[i];
RARRAY(ary)->ptr[i] = RARRAY(e)->ptr[1];