diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98a7642..00610d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: - id: versions run: | versions=$(curl -s 'https://cache.ruby-lang.org/pub/misc/ci_versions/all.json' | jq -c '. + ["2.5"]') - echo "::set-output name=value::${versions}" + echo "value=${versions}" >> $GITHUB_OUTPUT test: needs: ruby-versions name: build (${{ matrix.ruby }} / ${{ matrix.os }}) diff --git a/lib/optparse.rb b/lib/optparse.rb index dc2b8a0..53a4387 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -425,7 +425,7 @@ # If you have any questions, file a ticket at http://bugs.ruby-lang.org. # class OptionParser - OptionParser::Version = "0.3.0" + OptionParser::Version = "0.3.1" # :stopdoc: NoArgument = [NO_ARGUMENT = :NONE, nil].freeze @@ -2084,10 +2084,23 @@ def environment(env = File.basename($0, '.*')) 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 # diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb index 5a0593d..bfa705a 100644 --- a/test/optparse/test_optparse.rb +++ b/test/optparse/test_optparse.rb @@ -63,6 +63,9 @@ def test_regexp 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
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: