mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_enc_cr_str_buf_cat, rb_str_buf_append): deal with self
appending. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3f2d1892df
commit
9874fdbc86
2 changed files with 12 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Jan 9 14:52:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_enc_cr_str_buf_cat, rb_str_buf_append): deal with self
|
||||
appending.
|
||||
|
||||
Wed Jan 9 14:44:57 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_prepare): set parser->enc from lex_input for ripper.
|
||||
|
|
12
string.c
12
string.c
|
@ -1061,7 +1061,7 @@ static VALUE
|
|||
rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
|
||||
int ptr_encindex, int ptr_cr, int *ptr_cr_ret)
|
||||
{
|
||||
long capa, total;
|
||||
long capa, total, off = -1;
|
||||
|
||||
int str_encindex = ENCODING_GET(str);
|
||||
int res_encindex;
|
||||
|
@ -1128,7 +1128,13 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
|
|||
if (len < 0) {
|
||||
rb_raise(rb_eArgError, "negative string size (or size too big)");
|
||||
}
|
||||
if (ptr >= RSTRING_PTR(str) && ptr <= RSTRING_END(str)) {
|
||||
off = ptr - RSTRING_PTR(str);
|
||||
}
|
||||
rb_str_modify(str);
|
||||
if (off != -1) {
|
||||
ptr = RSTRING_PTR(str) + off;
|
||||
}
|
||||
if (len == 0) {
|
||||
ENCODING_CODERANGE_SET(str, res_encindex, res_cr);
|
||||
return str;
|
||||
|
@ -1170,10 +1176,6 @@ rb_str_buf_append(VALUE str, VALUE str2)
|
|||
{
|
||||
int str2_cr;
|
||||
|
||||
if (str == str2) {
|
||||
str2 = rb_str_dup(str2);
|
||||
}
|
||||
|
||||
str2_cr = ENC_CODERANGE(str2);
|
||||
|
||||
rb_enc_cr_str_buf_cat(str, RSTRING_PTR(str2), RSTRING_LEN(str2),
|
||||
|
|
Loading…
Add table
Reference in a new issue