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

* string.c (str_gsub): avoid appending empty pre-match substr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-01-08 06:04:26 +00:00
parent 893ee30978
commit 389abf1b3b
2 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Tue Jan 8 15:03:10 2008 Tanaka Akira <akr@fsij.org>
* string.c (str_gsub): avoid appending empty pre-match substr.
Tue Jan 8 13:05:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (iseq_build_from_ary), iseq.c (iseq_load): fix for format change.

View file

@ -2720,7 +2720,9 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
if (OBJ_TAINTED(val)) tainted = 1;
len = beg - offset; /* copy pre-match substr */
rb_enc_str_buf_cat(dest, cp, len, str_enc);
if (len) {
rb_enc_str_buf_cat(dest, cp, len, str_enc);
}
rb_str_buf_append(dest, val);