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_substr): copy encoding although empty string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-02-22 02:18:23 +00:00
parent 492dde9c09
commit 7a9cf391cd
2 changed files with 8 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Fri Feb 22 11:16:55 2008 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (rb_str_substr): copy encoding although empty string.
Fri Feb 22 04:48:22 2008 NARUSE, Yui <naruse@ruby-lang.org>
* string.c (rb_str_times): empty string's coderange is CODERANGE_7BIT.

View file

@ -1242,7 +1242,10 @@ rb_str_substr(VALUE str, long beg, long len)
else {
str2 = rb_str_new5(str, p, len);
if (len) rb_enc_cr_str_copy(str2, str);
else ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT);
else {
rb_enc_copy(str2, str);
ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT);
}
OBJ_INFECT(str2, str);
}