1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_splice): propagate encoding.

* string.c (rb_str_subpat_set): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-18 09:14:46 +00:00
parent 2521b33ed7
commit ec69dddc0d
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Tue Dec 18 18:09:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_splice): propagate encoding.
* string.c (rb_str_subpat_set): ditto.
Tue Dec 18 17:27:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_obj_freeze): preserve frozen state of immediate

View file

@ -2142,6 +2142,7 @@ rb_str_splice(VALUE str, long beg, long len, VALUE val)
beg = p - RSTRING_PTR(str); /* physical position */
len = e - p; /* physical length */
rb_str_splice_0(str, beg, len, val);
rb_enc_associate(str, enc);
}
void
@ -2155,6 +2156,7 @@ rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
{
VALUE match;
long start, end, len;
rb_encoding *enc;
if (rb_reg_search(re, str, 0, 0) < 0) {
rb_raise(rb_eIndexError, "regexp not matched");
@ -2178,8 +2180,9 @@ rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
end = RMATCH(match)->END(nth);
len = end - start;
StringValue(val);
rb_enc_check(str, val);
enc = rb_enc_check(str, val);
rb_str_splice_0(str, start, len, val);
rb_enc_associate(str, enc);
}
static VALUE