summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-19 04:35:17 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-19 04:35:17 +0000
commit9d51cf8a6a5d651c1c4dd363dbf3f4905e3f307d (patch)
tree98247086ea05415f034f0b5a0e6cc97163f47be2 /array.c
parent6aa71d4c800d11d9735007cf3b063e5ea2fc5941 (diff)
* eval.c (rb_f_require): searches ".rb" and ".so" at the same
time. previous behavior (search ".rb", then ".so") has a security risk (ruby-bugs#PR140). * array.c (rb_ary_to_ary): new function to replace internal rb_Array(), which never calls to_a, but to_ary (rb_Array() might call both). [new] * regex.c (PUSH_FAILURE_POINT): push option status again. * regex.c (re_compile_pattern): avoid pushing unnecessary option_set. * eval.c (rb_load): tainted string is OK if wrapped *and* $SAFE >= 4. * eval.c (rb_thread_start_0): should not nail down higher blocks before preserving original context (i.e. should not alter original context). * eval.c (proc_yield): new method equivalent to Proc#call but no check for number of arguments. [new] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/array.c b/array.c
index 010afd9a39..d0f6977a13 100644
--- a/array.c
+++ b/array.c
@@ -17,6 +17,7 @@
#include "st.h"
VALUE rb_cArray;
+static ID cmp;
#define ARY_DEFAULT_SIZE 16
@@ -729,6 +730,20 @@ to_ary(ary)
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
}
+VALUE
+rb_ary_to_ary(obj)
+ VALUE obj;
+{
+ if (NIL_P(obj)) return rb_ary_new2(0);
+ if (TYPE(obj) == T_ARRAY) {
+ return obj;
+ }
+ if (rb_respond_to(obj, rb_intern("to_ary"))) {
+ return rb_convert_type(obj, T_ARRAY, "Array", "to_ary");
+ }
+ return rb_ary_new3(1, obj);
+}
+
extern VALUE rb_output_fs;
static VALUE
@@ -958,8 +973,6 @@ rb_ary_reverse_m(ary)
return rb_ary_reverse(rb_obj_dup(ary));
}
-static ID cmp;
-
static int
sort_1(a, b)
VALUE *a, *b;