diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-21 08:08:36 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-21 08:08:36 +0000 |
commit | 2ca2a4a43bb018bfd84fccc75e395c1f0e58acc6 (patch) | |
tree | 60b46bd4507018b7c53ba2702d11119699c92779 /lib | |
parent | ad5f0fc6ccba716676a40c0a635fd41a8a782d4a (diff) | |
download | ruby-2ca2a4a43bb018bfd84fccc75e395c1f0e58acc6.tar.gz |
* parse.y (block_param): do not use multiple assignment for a sole
block parameter. [ruby-dev:28710]
* eval.c (rb_yield_0): pass a raw yielded value to a sole block
parameter if a value is passed by yield.
* eval.c (proc_invoke): args may not be an array.
* eval.c (rb_proc_yield): pass original value without wrapping
it in an array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/optparse.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index 6ecd7e3203..7e5fcba1ca 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -352,12 +352,12 @@ class OptionParser # : (({block})) # (({yields})) at semi-error condition, instead of raises exception. # - def conv_arg(arg, val = []) + def conv_arg(arg, val = nil) if block if conv - val = conv.yield(*val) + val = conv.yield(val) else - val = val[0] + val = *val end return arg, block, val else @@ -453,12 +453,12 @@ class OptionParser # # Raises an exception if argument is not present. # - def parse(arg, argv) + def parse(arg, argv, &error) unless arg raise MissingArgument if argv.empty? arg = argv.shift end - conv_arg(*parse_arg(arg) {|*exc| raise(*exc)}) + conv_arg(*parse_arg(arg), &error) end end @@ -622,7 +622,7 @@ class OptionParser if list = __send__(id) val = list.fetch(key) {return nil} return val unless block_given? - yield(*val) + yield(val) end end @@ -700,7 +700,7 @@ class OptionParser # Completion for hash key. # def match(key) - return key, fetch(key) { + return key, *fetch(key) { raise AmbiguousArgument, catch(:ambiguous) {return complete(key)} } end @@ -1495,9 +1495,9 @@ class OptionParser yielded with the found value when succeeded. =end #'#"#`# def search(id, key) - visit(:search, id, key) do |*k| + visit(:search, id, key) do |k| return k unless block_given? - return yield(*k) + return yield(k) end end private :search |