diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-17 15:35:09 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-17 15:35:09 +0000 |
| commit | 199dcd6406a26a6b49b13cc27c634d798cd7d23b (patch) | |
| tree | 34e47ea0718d9fccf2621ea3a67a18028de2bfba | |
| parent | 1dd02660bcebd599ed481e86b4cdb59865da74a8 (diff) | |
| download | ruby-199dcd6406a26a6b49b13cc27c634d798cd7d23b.tar.gz ruby-199dcd6406a26a6b49b13cc27c634d798cd7d23b.tar.xz ruby-199dcd6406a26a6b49b13cc27c634d798cd7d23b.zip | |
* re.c (rb_reg_regsub): don't repeat repl twice with
"X".sub!(/./, sprintf("\\%c", 255)).
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | re.c | 1 | ||||
| -rw-r--r-- | test/ruby/test_regexp.rb | 2 |
3 files changed, 7 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Mon Feb 18 00:33:03 2008 Tanaka Akira <akr@fsij.org> + + * re.c (rb_reg_regsub): don't repeat repl twice with + "X".sub!(/./, sprintf("\\%c", 255)). + Sun Feb 17 23:06:55 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com> * lib/cgi.rb (CGI::escapeHTML): use gsub with Hash. [ruby-dev:33828] @@ -2985,6 +2985,7 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp) if (c == -1) { s += mbclen(s, e, str_enc); rb_enc_str_buf_cat(val, ss, s-ss, str_enc); + p = s; continue; } s += clen; diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 813ade714..1f96a28b4 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -407,7 +407,7 @@ class TestRegexp < Test::Unit::TestCase assert_equal("fooXXXbaz", "foobarbaz".sub!(/bar/, "XXX")) s = [0xff].pack("C") assert_equal(s, "X".sub!(/./, s)) - assert_equal('\\' + s + '\\' + s, "X".sub!(/./, '\\' + s)) # ??? + assert_equal('\\' + s, "X".sub!(/./, '\\' + s)) assert_equal('\k', "foo".sub!(/.../, '\k')) assert_raise(RuntimeError) { "foo".sub!(/(?<x>o)/, '\k<x') } assert_equal('foo[bar]baz', "foobarbaz".sub!(/(b..)/, '[\0]')) |
