From: nobuyoshi nakada Date: 2005-09-26T16:26:53+09:00 Subject: [ruby-dev:27319] Re: [ruby-cvs:15644] ruby, ruby/lib: * lib/optparse.rb (RequiredArgument#parse): not consume unmatched なかだです。 At Mon, 26 Sep 2005 15:04:59 +0900, U.Nakamura wrote in [ruby-dev:27318]: > | * lib/optparse.rb (RequiredArgument#parse): not consume unmatched > | argument. fixed [ruby-dev:27316] > > この変更で、OptionParserが引数つきのオプション(-foo=BAR みた > いなもの)を一切受け付けなくなっています。 > 具体的にはRubyの構築ができません ;-( すいません、間違えました。帰ったら直すつもりでしたが。 Index: lib/optparse.rb =================================================================== RCS file: /src/ruby/lib/optparse.rb,v retrieving revision 1.51 diff -U2 -p -r1.51 optparse.rb --- lib/optparse.rb 25 Sep 2005 22:55:33 -0000 1.51 +++ lib/optparse.rb 26 Sep 2005 06:59:56 -0000 @@ -454,13 +454,10 @@ class OptionParser # Raises an exception if argument is not present. # - def parse(arg, argv, &error) - opt = (val = parse_arg(val, &error))[1] - val = conv_arg(*val) - if opt and !arg - argv.shift - else - val[0] = nil + def parse(arg, argv) + unless arg + raise MissingArgument if argv.empty? + arg = argv.shift end - val + conv_arg(*parse_arg(arg) {|*exc| raise(*exc)}) end end @@ -485,5 +482,5 @@ class OptionParser # Switch that takes an argument, which does not begin with '-'. # - class PlacedArgument < RequiredArgument + class PlacedArgument < self # # Returns nil if argument is not present or begins with '-'. @@ -493,5 +490,12 @@ class OptionParser return nil, block, nil end - super + opt = (val = parse_arg(val, &error))[1] + val = conv_arg(*val) + if opt and !arg + argv.shift + else + val[0] = nil + end + val end end -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦