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): should share the shared string if

present, instead of the original string.  (ruby-bugs:PR#528)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-12-30 07:55:17 +00:00
parent 3d2ddca6b2
commit c39a8e326a
2 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Mon Dec 30 16:44:14 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* string.c (rb_str_substr): should share the shared string if
present, instead of the original string. (ruby-bugs:PR#528)
Mon Dec 30 05:10:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* ext/socket/socket.c (tcp_svr_init): local host to

View file

@ -500,9 +500,12 @@ rb_str_substr(str, beg, len)
if (len > sizeof(struct RString)/2 &&
beg + len == RSTRING(str)->len &&
!FL_TEST(str, STR_ASSOC)) {
if (!FL_TEST(str, ELTS_SHARED)) str = str_new4(CLASS_OF(str), str);
if (FL_TEST(str, ELTS_SHARED))
str = RSTRING(str)->aux.shared;
else
str = str_new4(CLASS_OF(str), str);
str2 = rb_str_new3(str);
RSTRING(str2)->ptr += beg;
RSTRING(str2)->ptr += RSTRING(str2)->len - len;
RSTRING(str2)->len = len;
}
else {