Skip to content

Commit 104d379

Browse files
committed
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
2 parents 9d764f9 + ff3c7f9 commit 104d379

File tree

7 files changed

+350
-252
lines changed

7 files changed

+350
-252
lines changed

Documentation/technical/api-parse-options.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ There are some macros to easily define options:
137137
Introduce a boolean option.
138138
If used, `int_var` is bitwise-ored with `mask`.
139139

140+
`OPT_NEGBIT(short, long, &int_var, description, mask)`::
141+
Introduce a boolean option.
142+
If used, `int_var` is bitwise-anded with the inverted `mask`.
143+
140144
`OPT_SET_INT(short, long, &int_var, description, integer)`::
141145
Introduce a boolean option.
142146
If used, set `int_var` to `integer`.
@@ -166,6 +170,14 @@ There are some macros to easily define options:
166170
`OPT_ARGUMENT(long, description)`::
167171
Introduce a long-option argument that will be kept in `argv[]`.
168172

173+
`OPT_NUMBER_CALLBACK(&var, description, func_ptr)`::
174+
Recognize numerical options like -123 and feed the integer as
175+
if it was an argument to the function given by `func_ptr`.
176+
The result will be put into `var`. There can be only one such
177+
option definition. It cannot be negated and it takes no
178+
arguments. Short options that happen to be digits take
179+
precedence over it.
180+
169181

170182
The last element of the array must be `OPT_END()`.
171183

0 commit comments

Comments
 (0)