diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-30 09:12:34 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-30 09:12:34 +0000 |
commit | abfaac7a6cbdbfad9e7c05bc5ebcb4df57906fcb (patch) | |
tree | 4d406191345ff9f25e3a3c9ce5f85a3a13e6f7d1 /array.c | |
parent | 4cd1cd7201757185e63a5a33181932a6670887ad (diff) |
* ruby.c (proc_options): unexpected SecurityError happens when -T4.
* regex.c (re_compile_pattern): * \1 .. \9 should be
backreferences always.
* regex.c (re_match): backreferences corresponding to
unclosed/unmatched parentheses should fail always.
* string.c (rb_str_cat): use rb_str_buf_cat() if possible. [new]
* string.c (rb_str_append): ditto.
* string.c (rb_str_buf_cat): remove unnecessary check (type,
taint, modify) to gain performance.
* string.c (rb_str_buf_append): ditto.
* string.c (rb_str_buf_new): buffering string function. [new]
* string.c (rb_str_buf_append): ditto.
* string.c (rb_str_buf_cat): ditto.
* time.c (make_time_t): local time adjustment revised.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 40 |
1 files changed, 11 insertions, 29 deletions
@@ -739,26 +739,11 @@ inspect_join(ary, arg) return rb_ary_join(arg[0], arg[1]); } -static long -str_cpy(str, idx, str2) - VALUE str; - long idx; - VALUE str2; -{ - long len = idx + RSTRING(str2)->len; - - if (RSTRING(str)->len < len) { - rb_str_resize(str, len); - } - memcpy(RSTRING(str)->ptr+idx, RSTRING(str2)->ptr, RSTRING(str2)->len); - return len; -} - VALUE rb_ary_join(ary, sep) VALUE ary, sep; { - long len, i, j; + long len, i; int taint = 0; VALUE result, tmp; @@ -778,9 +763,8 @@ rb_ary_join(ary, sep) if (!NIL_P(sep) && TYPE(sep) == T_STRING) { len += RSTRING(sep)->len * RARRAY(ary)->len - 1; } - result = rb_str_new(0, len); - - for (i=0, j=0; i<RARRAY(ary)->len; i++) { + result = rb_str_buf_new(len); + for (i=0; i<RARRAY(ary)->len; i++) { tmp = RARRAY(ary)->ptr[i]; switch (TYPE(tmp)) { case T_STRING: @@ -800,11 +784,11 @@ rb_ary_join(ary, sep) default: tmp = rb_obj_as_string(tmp); } - if (i > 0 && !NIL_P(sep)) j = str_cpy(result, j, sep); - j = str_cpy(result, j, tmp); + if (i > 0 && !NIL_P(sep)) + rb_str_buf_append(result, sep); + rb_str_buf_append(result, tmp); if (OBJ_TAINTED(tmp)) taint = 1; } - rb_str_resize(result, j); if (taint) OBJ_TAINT(result); return result; @@ -909,16 +893,14 @@ inspect_ary(ary) long i = 0; VALUE s, str; - str = rb_str_new2("["); - + str = rb_str_buf_new2("["); for (i=0; i<RARRAY(ary)->len; i++) { s = rb_inspect(RARRAY(ary)->ptr[i]); - tainted = OBJ_TAINTED(s); - if (i > 0) rb_str_cat2(str, ", "); - rb_str_append(str, s); + if (OBJ_TAINTED(s)) tainted = 1; + if (i > 0) rb_str_buf_cat2(str, ", "); + rb_str_buf_append(str, s); } - rb_str_cat(str, "]", 1); - + rb_str_buf_cat2(str, "]"); if (tainted) OBJ_TAINT(str); return str; } |