@@ -10,7 +10,7 @@ enum parse_opt_type {
1010 /* options with no arguments */
1111 OPTION_BIT ,
1212 OPTION_NEGBIT ,
13- OPTION_BOOLEAN , /* _INCR would have been a better name */
13+ OPTION_COUNTUP ,
1414 OPTION_SET_INT ,
1515 OPTION_SET_PTR ,
1616 /* options with arguments (usually) */
@@ -21,6 +21,9 @@ enum parse_opt_type {
2121 OPTION_FILENAME
2222};
2323
24+ /* Deprecated synonym */
25+ #define OPTION_BOOLEAN OPTION_COUNTUP
26+
2427enum parse_opt_flags {
2528 PARSE_OPT_KEEP_DASHDASH = 1 ,
2629 PARSE_OPT_STOP_AT_NON_OPTION = 2 ,
@@ -122,10 +125,11 @@ struct option {
122125 PARSE_OPT_NOARG, NULL, (b) }
123126#define OPT_NEGBIT (s , l , v , h , b ) { OPTION_NEGBIT, (s), (l), (v), NULL, \
124127 (h), PARSE_OPT_NOARG, NULL, (b) }
125- #define OPT_BOOLEAN (s , l , v , h ) { OPTION_BOOLEAN , (s), (l), (v), NULL, \
128+ #define OPT_COUNTUP (s , l , v , h ) { OPTION_COUNTUP , (s), (l), (v), NULL, \
126129 (h), PARSE_OPT_NOARG }
127130#define OPT_SET_INT (s , l , v , h , i ) { OPTION_SET_INT, (s), (l), (v), NULL, \
128131 (h), PARSE_OPT_NOARG, NULL, (i) }
132+ #define OPT_BOOL (s , l , v , h ) OPT_SET_INT(s, l, v, h, 1)
129133#define OPT_SET_PTR (s , l , v , h , p ) { OPTION_SET_PTR, (s), (l), (v), NULL, \
130134 (h), PARSE_OPT_NOARG, NULL, (p) }
131135#define OPT_INTEGER (s , l , v , h ) { OPTION_INTEGER, (s), (l), (v), "n", (h) }
@@ -149,6 +153,13 @@ struct option {
149153 { OPTION_CALLBACK, (s), (l), (v), "when", (h), PARSE_OPT_OPTARG, \
150154 parse_opt_color_flag_cb, (intptr_t)"always" }
151155
156+ #define OPT_NOOP_NOARG (s , l ) \
157+ { OPTION_CALLBACK, (s), (l), NULL, NULL, \
158+ "no-op (backward compatibility)", \
159+ PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, parse_opt_noop_cb }
160+
161+ /* Deprecated synonym */
162+ #define OPT_BOOLEAN OPT_COUNTUP
152163
153164/* parse_options() will filter out the processed options and leave the
154165 * non-option arguments in argv[].
@@ -210,6 +221,7 @@ extern int parse_opt_verbosity_cb(const struct option *, const char *, int);
210221extern int parse_opt_with_commit (const struct option * , const char * , int );
211222extern int parse_opt_tertiary (const struct option * , const char * , int );
212223extern int parse_opt_string_list (const struct option * , const char * , int );
224+ extern int parse_opt_noop_cb (const struct option * , const char * , int );
213225
214226#define OPT__VERBOSE (var , h ) OPT_BOOLEAN('v', "verbose", (var), (h))
215227#define OPT__QUIET (var , h ) OPT_BOOLEAN('q', "quiet", (var), (h))
0 commit comments