зеркало из https://github.com/github/ruby.git
* enum.c (sort_by_cmp): check if reentered. [ruby-dev:24291]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
75d484a453
Коммит
a594151668
|
@ -1,3 +1,7 @@
|
|||
Sat Jul 14 14:04:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enum.c (sort_by_cmp): check if reentered. [ruby-dev:24291]
|
||||
|
||||
Sat Jul 14 11:08:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ext/json/ext/generator/generator.c (check_max_nesting): wrong
|
||||
|
|
7
enum.c
7
enum.c
|
@ -627,7 +627,11 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
|
|||
{
|
||||
VALUE a = (*(NODE *const *)ap)->u1.value;
|
||||
VALUE b = (*(NODE *const *)bp)->u1.value;
|
||||
VALUE ary = (VALUE)data;
|
||||
|
||||
if (RBASIC(ary)->klass) {
|
||||
rb_raise(rb_eRuntimeError, "sort_by reentered");
|
||||
}
|
||||
return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b);
|
||||
}
|
||||
|
||||
|
@ -717,7 +721,8 @@ enum_sort_by(VALUE obj)
|
|||
RBASIC(ary)->klass = 0;
|
||||
rb_block_call(obj, id_each, 0, 0, sort_by_i, ary);
|
||||
if (RARRAY_LEN(ary) > 1) {
|
||||
ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE), sort_by_cmp, 0);
|
||||
ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE),
|
||||
sort_by_cmp, (void *)ary);
|
||||
}
|
||||
if (RBASIC(ary)->klass) {
|
||||
rb_raise(rb_eRuntimeError, "sort_by reentered");
|
||||
|
|
Загрузка…
Ссылка в новой задаче