On Fri, Oct 05, 2007 at 03:33:44PM +0000, Kristian Høgsberg wrote: > On Fri, 2007-10-05 at 16:25 +0200, Pierre Habouzit wrote: > > The option parser takes argc, argv, an array of struct option > > and a usage string. Each of the struct option elements in the array > > describes a valid option, its type and a pointer to the location where the > > value is written. The entry point is parse_options(), which scans through > > the given argv, and matches each option there against the list of valid > > options. During the scan, argv is rewritten to only contain the > > non-option command line arguments and the number of these is returned. > > > > Aggregation of single switches is allowed: > > -rC0 is the same as -r -C 0 (supposing that -C wants an arg). > > > > Boolean switches automatically support the option with the same name, > > prefixed with 'no-' to disable the switch: > > --no-color / --color only need to have an entry for "color". > > > > Long options are supported either with '=' or without: > > --some-option=foo is the same as --some-option foo > > That looks great, works for me. One comment, though: it looks like > you're not sure whether to call these things "options" or "switches". > We should choose one and stick with it. I use the word "switch" when it's a short_option, and "option" when it's a long one. But maybe the distinction doesn't make sense, and it's a non-native speaker glitch. I don't care that much btw. > > oh and I don't grok what OPTION_LAST is for, so I left it apart, but > > it seems unused ? > > Oh, kill that. I used that as the option array terminator before we > switched to ARRAY_SIZE(). Okay :) -- ·O· Pierre Habouzit ··O madcoder@xxxxxxxxxx OOO http://www.madism.org
Attachment:
pgpHGVoqTq4I1.pgp
Description: PGP signature