From: Junio C Hamano Date: Sat, 23 May 2009 08:38:32 +0000 (-0700) Subject: Merge branch 'rs/grep-parseopt' X-Git-Tag: v1.6.4-rc0~143 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/104d3794481c83f8db00ccf85134fc55c76852f9?hp=-c Merge branch 'rs/grep-parseopt' * rs/grep-parseopt: grep: make callback functions static grep: use parseopt grep: remove global variable builtin_grep parseopt: add PARSE_OPT_NODASH parseopt: add OPT_NUMBER_CALLBACK parseopt: add OPT_NEGBIT --- 104d3794481c83f8db00ccf85134fc55c76852f9 diff --combined Documentation/technical/api-parse-options.txt index e30c602f47,beca98d754..b43458eae6 --- a/Documentation/technical/api-parse-options.txt +++ b/Documentation/technical/api-parse-options.txt @@@ -137,6 -137,10 +137,10 @@@ There are some macros to easily define Introduce a boolean option. If used, `int_var` is bitwise-ored with `mask`. + `OPT_NEGBIT(short, long, &int_var, description, mask)`:: + Introduce a boolean option. + If used, `int_var` is bitwise-anded with the inverted `mask`. + `OPT_SET_INT(short, long, &int_var, description, integer)`:: Introduce a boolean option. If used, set `int_var` to `integer`. @@@ -166,6 -170,14 +170,14 @@@ `OPT_ARGUMENT(long, description)`:: Introduce a long-option argument that will be kept in `argv[]`. + `OPT_NUMBER_CALLBACK(&var, description, func_ptr)`:: + Recognize numerical options like -123 and feed the integer as + if it was an argument to the function given by `func_ptr`. + The result will be put into `var`. There can be only one such + option definition. It cannot be negated and it takes no + arguments. Short options that happen to be digits take + precedence over it. + The last element of the array must be `OPT_END()`. @@@ -198,7 -210,7 +210,7 @@@ The function must be defined in this fo The callback mechanism is as follows: -* Inside `funct`, the only interesting member of the structure +* Inside `func`, the only interesting member of the structure given by `opt` is the void pointer `opt->value`. `\*opt->value` will be the value that is saved into `var`, if you use `OPT_CALLBACK()`.