* 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
This commit is contained in:
parent
e18e893846
commit
fb14b7eb05
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Thu Dec 13 17:26:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Thu Dec 13 17:03:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Dec 13 17:03:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* encoding.c (rb_enc_compatible): should swap encoding indexes too.
|
* encoding.c (rb_enc_compatible): should swap encoding indexes too.
|
||||||
|
11
string.c
11
string.c
@ -4091,7 +4091,9 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
|
|||||||
int last_null = 0;
|
int last_null = 0;
|
||||||
struct re_registers *regs;
|
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) {
|
while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
|
||||||
regs = RMATCH(rb_backref_get())->regs;
|
regs = RMATCH(rb_backref_get())->regs;
|
||||||
if (start == end && BEG(0) == END(0)) {
|
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;
|
if (NIL_P(rs)) return Qnil;
|
||||||
StringValue(rs);
|
StringValue(rs);
|
||||||
|
rb_enc_check(str, rs);
|
||||||
len = RSTRING_LEN(str);
|
len = RSTRING_LEN(str);
|
||||||
if (len == 0) return Qnil;
|
if (len == 0) return Qnil;
|
||||||
p = RSTRING_PTR(str);
|
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");
|
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);
|
len = str_strlen(str, enc);
|
||||||
if (width < 0 || len >= width) return rb_str_dup(str);
|
if (width < 0 || len >= width) return rb_str_dup(str);
|
||||||
n = width - len;
|
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));
|
STR_SET_LEN(res, p-RSTRING_PTR(res));
|
||||||
OBJ_INFECT(res, str);
|
OBJ_INFECT(res, str);
|
||||||
if (!NIL_P(pad)) OBJ_INFECT(res, pad);
|
if (!NIL_P(pad)) OBJ_INFECT(res, pad);
|
||||||
|
rb_enc_associate(res, enc);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user