[#8815] Segfault in libc strlen, via rb_str_new2 — "Sean E. Russell" <ser@...>

Howdy,

12 messages 2006/09/09
[#8817] Re: Segfault in libc strlen, via rb_str_new2 — Eric Hodel <drbrain@...7.net> 2006/09/09

On Sep 8, 2006, at 10:10 PM, Sean E. Russell wrote:

Re: [PATCH] OptionParser < Hash

From: "greg weber" <eegreg@...>
Date: 2006-09-10 15:49:55 UTC
List: ruby-core #8827
Think I forgot to attach the patch.

On 9/10/06, greg weber <eegreg@gmail.com> wrote:
> Hi,
>
> From the example in the code of optparse.rb, It seems to me that we
> are making users of optparse go to the extra effor of creating a
> wrapper class for OptionParser.
> This is a 5 line patch will allow for the use of OptionParser itself
> to automatically store values from options.  Now options can be built
> in the following manner:
>
> #example.rb -d 5
>
> require 'optparse'
>
> opts = OptionParser.new do |o|
>   # Cast 'delay' argument to a Float.
>   o.on("--delay N", Float, "Delay N seconds before executing") {|n| n}
> end
>
> opts.parse!(ARGV)
> p opts
> #{:delay=>5.0}
>
> By default, there will be a hash key for the long form of the option
> and its value will be the return of the block.  If necessary, this can
> be avoided by returning nil.
>
> This patch is against 1.40.2.12
> Include in the patch is an updated full example.
> I was also wondering if there is any way to specify mutually exclusive
> or required options with optparse.
>
> Greg Weber
>
>

Attachments (1)

optparse.rb (44.5 KB, application/x-ruby)

In This Thread