summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-26 12:44:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-26 12:44:47 +0000
commit54ca4e2269ffd818dcd2bd36ea474c03e1ad64af (patch)
tree9c78117631ebfb93147d8e0bfe5fef7f09ee5a04
parente516696847b6cbe90e581e0370b7b15ef83b68d1 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/optparse.rb24
2 files changed, 14 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 3aaa7a24a2..2f7161eb3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,3 @@
-Mon Sep 26 07:55:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (RequiredArgument#parse): not consume unmatched
- argument. fixed [ruby-dev:27316]
-
Sun Sep 25 12:05:10 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* bin/erb: typo fixed.
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 18ffe123e7..6668f30c8b 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -441,15 +441,12 @@ 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
@@ -472,7 +469,7 @@ 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 '-'.
#
@@ -480,7 +477,14 @@ class OptionParser
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
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
end