mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (ev_const_defined, ev_const_get), variable.c
(rb_const_get_at, rb_const_get, rb_mod_remove_const): use Qundef as autoload marker. [ruby-dev:18103], [ruby-dev:18184] * eval.c (rb_mod_autoload, rb_mod_autoload_p): new method; Module#autoload, Module#autoload?. * variable.c (rb_autoload, rb_autoload_load, rb_autoload_p): manage autoload constants per classes/modules. * variable.c (rb_const_defined_at, rb_const_defined): return false for autoloading constants. * class.c (rb_define_class, rb_define_module), eval.c (rb_eval), variable.c (rb_mod_const_at, rb_const_assign): removed autoload stuff. * intern.h: prototypes; rb_autoload, rb_autoload_load, rb_autoload_p. * lib/optparse.rb (OptionParser::Switch::PlacedArgument::parse): do not treat unmatched argument as an option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
144caca6bb
commit
5ddce4f7bc
6 changed files with 287 additions and 156 deletions
|
@ -223,7 +223,7 @@ Individual switch class.
|
|||
def parse(arg, *val)
|
||||
if block
|
||||
val = conv.call(*val) if conv
|
||||
return arg, block, val
|
||||
return arg, block, *val
|
||||
else
|
||||
return arg, nil
|
||||
end
|
||||
|
@ -343,11 +343,17 @@ Switch that can omit argument.
|
|||
|
||||
class PlacedArgument < self
|
||||
def parse(arg, argv, &error)
|
||||
unless arg
|
||||
return nil, block, nil if argv.empty? or /\A-/ =~ argv[0]
|
||||
arg = argv.shift
|
||||
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
|
||||
return nil, block, nil
|
||||
end
|
||||
super(*parse_arg(arg, &error))
|
||||
if (val = parse_arg(val, &error))[1]
|
||||
arg = nil
|
||||
else
|
||||
val[0] = arg
|
||||
end
|
||||
*val = super(*val)
|
||||
argv.shift unless arg
|
||||
val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1116,8 +1122,8 @@ Default options, which never appear in option summary.
|
|||
raise $!.set_option(arg, true)
|
||||
end
|
||||
begin
|
||||
opt, sw, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
|
||||
sw.call(val) if sw
|
||||
opt, sw, *val = sw.parse(rest, argv) {|*exc| raise(*exc)}
|
||||
sw.call(*val) if sw
|
||||
rescue ParseError
|
||||
raise $!.set_option(arg, rest)
|
||||
end
|
||||
|
@ -1143,10 +1149,10 @@ Default options, which never appear in option summary.
|
|||
raise $!.set_option(arg, true)
|
||||
end
|
||||
begin
|
||||
opt, sw, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
|
||||
opt, sw, *val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
|
||||
raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
|
||||
argv.unshift(opt) if opt and (opt = opt.sub(/\A-*/, '-')) != '-'
|
||||
sw.call(val) if sw
|
||||
sw.call(*val) if sw
|
||||
rescue ParseError
|
||||
raise $!.set_option(arg, has_arg)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue