mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (string.c): call rb_str_buf_append to update encoding of
str1, even if str2 is empty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
857b3018dd
commit
e350fe247a
2 changed files with 20 additions and 19 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jan 11 23:22:31 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (string.c): call rb_str_buf_append to update encoding of
|
||||
str1, even if str2 is empty.
|
||||
|
||||
Fri Jan 11 20:20:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* proc.c (proc_mark): needs to mark the receiver too. a patch from
|
||||
|
|
34
string.c
34
string.c
|
@ -1194,26 +1194,22 @@ rb_str_append(VALUE str, VALUE str2)
|
|||
int cr, cr2;
|
||||
|
||||
StringValue(str2);
|
||||
if (RSTRING_LEN(str2) > 0) {
|
||||
if (STR_ASSOC_P(str)) {
|
||||
long len = RSTRING_LEN(str)+RSTRING_LEN(str2);
|
||||
enc = rb_enc_check(str, str2);
|
||||
cr = ENC_CODERANGE(str);
|
||||
if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2;
|
||||
rb_str_modify(str);
|
||||
REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1);
|
||||
memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len,
|
||||
RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
|
||||
RSTRING(str)->as.heap.len = len;
|
||||
rb_enc_associate(str, enc);
|
||||
ENC_CODERANGE_SET(str, cr);
|
||||
}
|
||||
else {
|
||||
return rb_str_buf_append(str, str2);
|
||||
}
|
||||
if (RSTRING_LEN(str2) > 0 && STR_ASSOC_P(str)) {
|
||||
long len = RSTRING_LEN(str)+RSTRING_LEN(str2);
|
||||
enc = rb_enc_check(str, str2);
|
||||
cr = ENC_CODERANGE(str);
|
||||
if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2;
|
||||
rb_str_modify(str);
|
||||
REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1);
|
||||
memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len,
|
||||
RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
|
||||
RSTRING(str)->as.heap.len = len;
|
||||
rb_enc_associate(str, enc);
|
||||
ENC_CODERANGE_SET(str, cr);
|
||||
OBJ_INFECT(str, str2);
|
||||
return str;
|
||||
}
|
||||
OBJ_INFECT(str, str2);
|
||||
return str;
|
||||
return rb_str_buf_append(str, str2);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue