* re.c (rb_reg_regsub): don't repeat repl twice with

"X".sub!(/./, sprintf("\\%c", 255)).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-02-17 15:35:09 +00:00
Родитель adc639bb26
Коммит 583a4b1774
3 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -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]

1
re.c
Просмотреть файл

@ -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;

Просмотреть файл

@ -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]'))