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

string.c: coderange appending to empty string

* string.c (rb_enc_cr_str_buf_cat, rb_str_append): consider an empty
  string 7bit-clean and should not discard cached coderange of string
  to be appended.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-07-01 06:03:45 +00:00
parent 72d3e2b102
commit 78b45a0bc0
2 changed files with 9 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Mon Jul 1 15:03:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_enc_cr_str_buf_cat, rb_str_append): consider an empty
string 7bit-clean and should not discard cached coderange of string
to be appended.
Mon Jul 1 12:56:41 2013 Shugo Maeda <shugo@ruby-lang.org>
* eval.c (rb_using_module): activate refinements in the ancestors of

View file

@ -1958,7 +1958,7 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
int res_encindex;
int str_cr, res_cr;
str_cr = ENC_CODERANGE(str);
str_cr = RSTRING_LEN(str) ? ENC_CODERANGE(str) : ENC_CODERANGE_7BIT;
if (str_encindex == ptr_encindex) {
if (str_cr == ENC_CODERANGE_UNKNOWN)
@ -2095,7 +2095,8 @@ rb_str_append(VALUE str, VALUE str2)
long len = RSTRING_LEN(str) + len2;
enc = rb_enc_check(str, str2);
cr = ENC_CODERANGE(str);
if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2;
if ((cr2 = ENC_CODERANGE(str2)) > cr || RSTRING_LEN(str) == 0)
cr = cr2;
rb_str_modify_expand(str, len2);
memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len,
RSTRING_PTR(str2), len2+1);