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:
parent
2521b33ed7
commit
ec69dddc0d
2 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
5
string.c
5
string.c
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue