Re: [PATCH 6/7] parse-opt: add PARSE_OPT_KEEP_ARGV0 parser option.
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.
Hmm?
Linus