diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-18 16:48:15 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-18 16:48:15 +0000 |
| commit | 392d9e755b281d9f1be59f44672bdc71f3f7c386 (patch) | |
| tree | 76b375eab548c3864ef1dd3a619a6b564d6d81fd | |
| parent | 10b864e17c5c058537e8100a90eea0267337f936 (diff) | |
| download | ruby-392d9e755b281d9f1be59f44672bdc71f3f7c386.tar.gz ruby-392d9e755b281d9f1be59f44672bdc71f3f7c386.tar.xz ruby-392d9e755b281d9f1be59f44672bdc71f3f7c386.zip | |
merges r20242 from trunk into ruby_1_9_1. recovers 1.8-compatible
parsing for OptionParser.
* lib/optparse.rb (OptionParser::make_switch): makes default
conversion to splat. [ruby-list:45645]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | lib/optparse.rb | 7 |
2 files changed, 11 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Tue Nov 18 09:42:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/optparse.rb (OptionParser::make_switch): makes default + conversion to splat. [ruby-list:45645] + Mon Nov 17 18:05:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * enc/depend (LIBS): fixed for disable-shared. [ruby-dev:37103] diff --git a/lib/optparse.rb b/lib/optparse.rb index 5a86194b7..0548a29ca 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -996,6 +996,7 @@ class OptionParser end private :notwice + SPLAT_PROC = proc {|*a| a} # # Creates an OptionParser::Switch from the parameters. The parsed argument # value is passed to the given block, where it can be processed. @@ -1076,7 +1077,11 @@ class OptionParser # directly specified pattern(any object possible to match) if (!(String === o || Symbol === o)) and o.respond_to?(:match) pattern = notwice(o, pattern, 'pattern') - conv = pattern.method(:convert).to_proc if pattern.respond_to?(:convert) + if pattern.respond_to?(:convert) + conv = pattern.method(:convert).to_proc + else + conv = SPLAT_PROC + end next end |
