Bug #541: cgi.rb : obsolete regex “n” option
http://redmine.ruby-lang.org/issues/show/541
e$B5/I<<Te(B: Takeyuki F.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
CGI::prettye$B$N@55,I=8=ItJ,$Ke(Bne$B$,;H$o$l$F$$$k$N$Ge(B
warninge$B$,=P$^$9!#e(B
Index: lib/cgi.rb
— lib/cgi.rb (e$B%j%S%8%g%se(B 19071)
+++ lib/cgi.rb (e$B:n6H%3%T!<e(B)
@@ -1245,14 +1245,14 @@
#
def CGI::pretty(string, shift = " ")
- lines = string.gsub(/(?!\A)<(?:.|\n)?>/n,
“\n\0”).gsub(/<(?:.|\n)?>(?!\n)/n, “\0\n”)
- lines = string.gsub(/(?!\A)<(?:.|\n)?>/,
“\n\0”).gsub(/<(?:.|\n)?>(?!\n)/, “\0\n”)
end_pos = 0
- while end_pos = lines.index(/^</(\w+)/n, end_pos)
- while end_pos = lines.index(/^</(\w+)/, end_pos)
element = $1.dup
-
start_pos = lines.rindex(/^\s*<#{element}/ni, end_pos)
-
lines[start_pos ... end_pos] = "__" + lines[start_pos ...
end_pos].gsub(/\n(?!\z)/n, “\n” + shift) + “__”
-
start_pos = lines.rindex(/^\s*<#{element}/i, end_pos)
-
lines[start_pos ... end_pos] = "__" + lines[start_pos ...
end_pos].gsub(/\n(?!\z)/, “\n” + shift) + “__”
end
- lines.gsub(/^((?:#{Regexp::quote(shift)})*)__(?=</?\w)/n, ‘\1’)
- lines.gsub(/^((?:#{Regexp::quote(shift)})*)__(?=</?\w)/, ‘\1’)
end