diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-13 08:28:40 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-13 08:28:40 +0000 |
commit | fb14b7eb05f9a2e378ebb69d2cbf001c3f4edbc3 (patch) | |
tree | 7a99dab936f1e0f5393b5f67bab8ae09ee3deed5 /string.c | |
parent | e18e89384675fb9e0923bbea6c8923d99b8abdbf (diff) | |
download | ruby-fb14b7eb05f9a2e378ebb69d2cbf001c3f4edbc3.tar.gz |
* string.c (rb_str_split_m): need not to check encoding if regexp
is empty.
* string.c (rb_str_justify): associate encoding of original to the
result.
* string.c (rb_str_chomp_bang): need to check encoding of record
separator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -4091,7 +4091,9 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str) int last_null = 0; struct re_registers *regs; - enc = rb_enc_check(str, spat); + if (RREGEXP(spat)->len != 0) { + enc = rb_enc_check(str, spat); + } while ((end = rb_reg_search(spat, str, start, 0)) >= 0) { regs = RMATCH(rb_backref_get())->regs; if (start == end && BEG(0) == END(0)) { @@ -4456,6 +4458,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) } if (NIL_P(rs)) return Qnil; StringValue(rs); + rb_enc_check(str, rs); len = RSTRING_LEN(str); if (len == 0) return Qnil; p = RSTRING_PTR(str); @@ -4992,11 +4995,6 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag) rb_raise(rb_eArgError, "zero width padding"); } } -#if 0 - else if (!m17n_asciicompat(enc)) { - rb_raise(rb_eArgError, "character encodings differ"); - } -#endif len = str_strlen(str, enc); if (width < 0 || len >= width) return rb_str_dup(str); n = width - len; @@ -5046,6 +5044,7 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag) STR_SET_LEN(res, p-RSTRING_PTR(res)); OBJ_INFECT(res, str); if (!NIL_P(pad)) OBJ_INFECT(res, pad); + rb_enc_associate(res, enc); return res; } |