mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (str_buf_cat): check for self concatenation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
64bce8a8ad
commit
6f42fdc564
2 changed files with 12 additions and 1 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Jun 22 07:16:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (str_buf_cat): check for self concatenation.
|
||||||
|
|
||||||
Sat Jun 21 15:57:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Jun 21 15:57:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/rdoc/parsers/parse_rb.rb (RDoc#collect_first_comment): skip
|
* lib/rdoc/parsers/parse_rb.rb (RDoc#collect_first_comment): skip
|
||||||
|
|
|
||||||
9
string.c
9
string.c
|
|
@ -708,9 +708,13 @@ str_buf_cat(str, ptr, len)
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
long len;
|
long len;
|
||||||
{
|
{
|
||||||
long capa, total;
|
long capa, total, off = -1;;
|
||||||
|
|
||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
|
if (ptr >= RSTRING(str)->ptr && ptr <= RSTRING(str)->ptr + RSTRING(str)->len) {
|
||||||
|
off = ptr - RSTRING(str)->ptr;
|
||||||
|
}
|
||||||
|
if (len == 0) return 0;
|
||||||
if (FL_TEST(str, STR_ASSOC)) {
|
if (FL_TEST(str, STR_ASSOC)) {
|
||||||
FL_UNSET(str, STR_ASSOC);
|
FL_UNSET(str, STR_ASSOC);
|
||||||
capa = RSTRING(str)->aux.capa = RSTRING(str)->len;
|
capa = RSTRING(str)->aux.capa = RSTRING(str)->len;
|
||||||
|
|
@ -732,6 +736,9 @@ str_buf_cat(str, ptr, len)
|
||||||
}
|
}
|
||||||
RESIZE_CAPA(str, capa);
|
RESIZE_CAPA(str, capa);
|
||||||
}
|
}
|
||||||
|
if (off != -1) {
|
||||||
|
ptr = RSTRING(str)->ptr + off;
|
||||||
|
}
|
||||||
memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len);
|
memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len);
|
||||||
RSTRING(str)->len = total;
|
RSTRING(str)->len = total;
|
||||||
RSTRING(str)->ptr[total] = '\0'; /* sentinel */
|
RSTRING(str)->ptr[total] = '\0'; /* sentinel */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue