diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | string.c | 2 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 6 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 14 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Thu Sep 12 01:44:01 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * string.c (str_gsub): use BEG(0) for whole matched position not + return value from rb_reg_search(), for \K matching. + [ruby-dev:47694] [Bug #8856] + Thu Sep 12 01:34:07 2013 Charlie Somerville <charliesome@ruby-lang.org> * object.c (rb_class_inherited_p): allow iclasses to be tested for @@ -3905,7 +3905,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang) if (OBJ_TAINTED(val)) tainted = 1; - len = beg - offset; /* copy pre-match substr */ + len = beg0 - offset; /* copy pre-match substr */ if (len) { rb_enc_str_buf_cat(dest, cp, len, str_enc); } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index a62e004918..5f719d40d7 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -500,6 +500,12 @@ class TestRegexp < Test::Unit::TestCase assert_equal('foo[\z]baz', "foobarbaz".sub!(/(b..)/, '[\z]')) end + def test_regsub_K + bug8856 = '[ruby-dev:47694] [Bug #8856]' + result = "foobarbazquux/foobarbazquux".gsub(/foo\Kbar/, "") + assert_equal('foobazquux/foobazquux', result, bug8856) + end + def test_KCODE assert_nil($KCODE) assert_nothing_raised { $KCODE = nil } @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-09-12" -#define RUBY_PATCHLEVEL 303 +#define RUBY_PATCHLEVEL 304 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 9 |