Re: [PATCH 6/7] parse-opt: add PARSE_OPT_KEEP_ARGV0 parser option.
On Tue, Jun 24, 2008 at 05:18:56PM +0000, Linus Torvalds wrote:
Show 20 quoted lines
>
>
> On Tue, 24 Jun 2008, Pierre Habouzit wrote:
> >
> > This way, argv[0] isn't clobbered, to the cost of maybe not having a
> > resulting NULL terminated argv array.
>
> Umm. I think it's much easier to do by always having
>
> ctx->out = argv;
>
> and then just initializing cpix to 0 or 1:
>
> ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
>
> because now parse_options_end() doesn't need to play games any more. It
> doesn't need to care about PARSE_OPT_KEEP_ARGV0, it can just do exactly
> what it always used to do, because "ctx->cpidx + ctx->argc" automatically
> does the right thing (it is both the return value _and_ the index that you
> should fill with NULL.
Oh right, ack it's more elegant.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org