parse-options: make it possible to have option "subtables"parseopt
commitf24a88fb7f5cfb4fa7f8f1fb71ecdb879f5541b0
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 23 Jun 2008 12:14:48 +0000 (23 13:14 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 23 Jun 2008 12:24:48 +0000 (23 13:24 +0100)
tree5ba7f675bef132f66388ddb251148869046e429b
parent23de810ef12af15d077e0ab273b637d57b684cdc
parse-options: make it possible to have option "subtables"

Some programs share an awful lot of options, such as for the diff
machinery.  Allow an option table to recurse into another option
table with the new OPTION_OPTIONS() directive.

The subtable is expected to store the values into a struct whose address
is passed as 2nd parameter to OPTION_OPTIONS().

Subtables can recurse into subtables, too.

Example:

#define null ((struct diff_options *)NULL)
struct option diff__options[] = {
OPT_INTEGER('l', NULL, &null->rename_limit,
"set rename limit"),
[...]
};

struct option diff_files__options[] = {
[...]
OPTION_OPTIONS(diff__options, &revopt.diff_options),
[...]
};

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
parse-options.c
parse-options.h
test-parse-options.c