mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
merge revision(s) 55228: [Backport #12438]
* lib/optparse.rb (OptionParser::Completion.candidate): get rid of nil as key names. [ruby-core:75773] [Bug #12438] * lib/optparse.rb (OptionParser#make_switch): char class option cannot be NoArgument, default to RequiredArgument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
68c4c9d24c
commit
a11bb4fa91
4 changed files with 34 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Mon Jun 20 02:38:29 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/optparse.rb (OptionParser::Completion.candidate): get rid of
|
||||||
|
nil as key names. [ruby-core:75773] [Bug #12438]
|
||||||
|
|
||||||
|
* lib/optparse.rb (OptionParser#make_switch): char class option
|
||||||
|
cannot be NoArgument, default to RequiredArgument.
|
||||||
|
|
||||||
Mon Jun 20 02:25:44 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon Jun 20 02:25:44 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* re.c (unescape_nonascii): scan hex up to only 3 characters.
|
* re.c (unescape_nonascii): scan hex up to only 3 characters.
|
||||||
|
|
|
@ -413,7 +413,7 @@ class OptionParser
|
||||||
candidates = []
|
candidates = []
|
||||||
block.call do |k, *v|
|
block.call do |k, *v|
|
||||||
(if Regexp === k
|
(if Regexp === k
|
||||||
kn = nil
|
kn = "".freeze
|
||||||
k === key
|
k === key
|
||||||
else
|
else
|
||||||
kn = defined?(k.id2name) ? k.id2name : k
|
kn = defined?(k.id2name) ? k.id2name : k
|
||||||
|
@ -1336,6 +1336,7 @@ XXX
|
||||||
default_pattern = nil
|
default_pattern = nil
|
||||||
klass = nil
|
klass = nil
|
||||||
q, a = nil
|
q, a = nil
|
||||||
|
has_arg = false
|
||||||
|
|
||||||
opts.each do |o|
|
opts.each do |o|
|
||||||
# argument class
|
# argument class
|
||||||
|
@ -1414,6 +1415,8 @@ XXX
|
||||||
if a
|
if a
|
||||||
default_style = default_style.guess(arg = a)
|
default_style = default_style.guess(arg = a)
|
||||||
default_pattern, conv = search(:atype, o) unless default_pattern
|
default_pattern, conv = search(:atype, o) unless default_pattern
|
||||||
|
else
|
||||||
|
has_arg = true
|
||||||
end
|
end
|
||||||
sdesc << "-#{q}"
|
sdesc << "-#{q}"
|
||||||
short << Regexp.new(q)
|
short << Regexp.new(q)
|
||||||
|
@ -1436,6 +1439,9 @@ XXX
|
||||||
|
|
||||||
default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
|
default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
|
||||||
if !(short.empty? and long.empty?)
|
if !(short.empty? and long.empty?)
|
||||||
|
if has_arg and default_style == Switch::NoArgument
|
||||||
|
default_style = Switch::RequiredArgument
|
||||||
|
end
|
||||||
s = (style || default_style).new(pattern || default_pattern,
|
s = (style || default_style).new(pattern || default_pattern,
|
||||||
conv, sdesc, ldesc, arg, desc, block)
|
conv, sdesc, ldesc, arg, desc, block)
|
||||||
elsif !block
|
elsif !block
|
||||||
|
|
18
test/optparse/test_cclass.rb
Normal file
18
test/optparse/test_cclass.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# frozen_string_literal: false
|
||||||
|
require_relative 'test_optparse'
|
||||||
|
|
||||||
|
class TestOptionParser::CClass < TestOptionParser
|
||||||
|
def test_no_argument
|
||||||
|
flags = []
|
||||||
|
@opt.def_option("-[a-z]") {|x| flags << x}
|
||||||
|
no_error {@opt.parse!(%w"-a")}
|
||||||
|
assert_equal(%w"a", flags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_required_argument
|
||||||
|
flags = []
|
||||||
|
@opt.def_option("-[a-z]X") {|x| flags << x}
|
||||||
|
no_error {@opt.parse!(%w"-a")}
|
||||||
|
assert_equal(%w"a", flags)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.3.2"
|
#define RUBY_VERSION "2.3.2"
|
||||||
#define RUBY_RELEASE_DATE "2016-06-20"
|
#define RUBY_RELEASE_DATE "2016-06-20"
|
||||||
#define RUBY_PATCHLEVEL 134
|
#define RUBY_PATCHLEVEL 135
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2016
|
#define RUBY_RELEASE_YEAR 2016
|
||||||
#define RUBY_RELEASE_MONTH 6
|
#define RUBY_RELEASE_MONTH 6
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue