ruby-changes:2720
From: ko1@a...
Date: 13 Dec 2007 17:32:36 +0900
Subject: [ruby-changes:2720] matz - Ruby:r14211 (trunk): * string.c (rb_str_split_m): need not to check encoding if regexp
matz 2007-12-13 17:28:40 +0900 (Thu, 13 Dec 2007)
New Revision: 14211
Modified files:
trunk/ChangeLog
trunk/string.c
Log:
* 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.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=14211&r2=14210
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14211&r2=14210
Index: ChangeLog
===================================================================
--- ChangeLog (revision 14210)
+++ ChangeLog (revision 14211)
@@ -1,3 +1,14 @@
+Thu Dec 13 17:26:17 2007 Yukihiro Matsumoto <matz@r...>
+
+ * 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@r...>
* encoding.c (rb_enc_compatible): should swap encoding indexes too.
Index: string.c
===================================================================
--- string.c (revision 14210)
+++ string.c (revision 14211)
@@ -4091,7 +4091,9 @@
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 @@
}
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_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 @@
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;
}
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml