On Mon, Jun 23, 2008 at 10:38:11PM +0000, Junio C Hamano wrote: > Pierre Habouzit <madcoder@xxxxxxxxxx> writes: > > > Though I didn't fixed the fact that parse_options clobbers argv[0], > > which can be easily fixed. The issue with that is that _some_ callers > > use the fact that the filtered argv is NULL terminated. > > Isn't it just the matter of (1) leave argv[0] as is, (2) start copy dest > at argv[1] not argv[0], and (3) terminate argv[nargc] = NULL where nargc > is what you did not handle? > > You have argc args in incoming argv[], you consume zero or more of them > starting from argv[1] up to potentially argv[argc-1] (and argv[argc] is > NULL). So why is it an issue? Sorry, I do not understand. Are we sure argv[argc] is NULL when those are main() arguments ? If yes there is no issue, and I should read posix more carefully, but I was under the impression that POSIX wasn't enforcing that. Unrelated but worth to note: many parse_options users just don't care about argv[0] and having it kept each time would rather be a pain for them (they would need to call argv++, argc-- themselves). -- ·O· Pierre Habouzit ··O madcoder@xxxxxxxxxx OOO http://www.madism.org
Attachment:
pgpP18lYfvVUK.pgp
Description: PGP signature