[#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: Nobuyoshi Nakada <nobu@...>
Date: 2006-09-13 13:41:27 UTC
List: ruby-core #8858
Hi,

At Wed, 13 Sep 2006 19:40:04 +0900,
greg weber wrote in [ruby-core:08856]:
> This is great, Nobu!

Though I forgot to mention the usage, I'm glad you to see it.

> I added lazy switch creation with new(), so if a program is called
> without any arguments or exits before calling the parsing functions,
> it will run much faster.  Also, I pass the result hash into the new
> block if user desires to assign keys to it in addition to the
> defaults.

In usual, I write as:

  OptionParser.new do |opt|
    opt.on ...
    opt.parse!
  end

or:

  ARGV.options do |opt|
    opt.on ...
    opt.parse!
  end

There is no chance to run the block.

Also, the registration isn't restricted in one place.
Application and libraries can share an OptionParser instance,
especially ARGV.options.

> 758c758
> <     yield self if block_given?
> ---
> >     @setup = block_given? ? (lambda &block) : nil

It's a very roundabout way equivalent to `@setup = block'.

BTW, could you use unified diff?

-- 
Nobu Nakada

In This Thread

Prev Next