зеркало из https://github.com/github/ruby.git
[ruby/optparse] The encoding argument of `Regexp.new` has been ignored since 1.9
https://github.com/ruby/optparse/commit/766f567405
This commit is contained in:
Родитель
afd46429fc
Коммит
502ca37dde
|
@ -2084,10 +2084,23 @@ XXX
|
|||
f |= Regexp::IGNORECASE if /i/ =~ o
|
||||
f |= Regexp::MULTILINE if /m/ =~ o
|
||||
f |= Regexp::EXTENDED if /x/ =~ o
|
||||
k = o.delete("imx")
|
||||
k = nil if k.empty?
|
||||
case o = o.delete("imx")
|
||||
when ""
|
||||
when "u"
|
||||
s = s.encode(Encoding::UTF_8)
|
||||
when "e"
|
||||
s = s.encode(Encoding::EUC_JP)
|
||||
when "s"
|
||||
s = s.encode(Encoding::SJIS)
|
||||
when "n"
|
||||
f |= Regexp::NOENCODING
|
||||
else
|
||||
raise OptionParser::InvalidArgument, "unknown regexp option - #{o}"
|
||||
end
|
||||
else
|
||||
s ||= all
|
||||
end
|
||||
Regexp.new(s || all, f, k)
|
||||
Regexp.new(s, f)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -63,6 +63,9 @@ class TestOptionParser < Test::Unit::TestCase
|
|||
assert_equal(/foo/i, @reopt)
|
||||
assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/n")})
|
||||
assert_equal(/foo/n, @reopt)
|
||||
assert_equal(%w"", no_error {@opt.parse!(%W"--regexp=/\u{3042}/s")})
|
||||
assert_equal(Encoding::Windows_31J, @reopt.encoding)
|
||||
assert_equal("\x82\xa0".force_encoding(Encoding::Windows_31J), @reopt.source)
|
||||
end
|
||||
|
||||
def test_into
|
||||
|
|
Загрузка…
Ссылка в новой задаче