Skip to content

Commit 0171dbc

Browse files
ahuntgitster
authored andcommitted
parse-options: convert bitfield values to use binary shift
Because it's easier to read, but also likely to be easier to maintain. I am making this change because I need to add a new flag in a later commit. Also add a trailing comma to the last enum entry to simplify addition of new flags. This change was originally suggested by Peff in: https://public-inbox.org/git/YEZ%[email protected]/ Signed-off-by: Andrzej Hunt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04fe4d7 commit 0171dbc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

parse-options.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@ enum parse_opt_type {
2828
};
2929

3030
enum parse_opt_flags {
31-
PARSE_OPT_KEEP_DASHDASH = 1,
32-
PARSE_OPT_STOP_AT_NON_OPTION = 2,
33-
PARSE_OPT_KEEP_ARGV0 = 4,
34-
PARSE_OPT_KEEP_UNKNOWN = 8,
35-
PARSE_OPT_NO_INTERNAL_HELP = 16,
36-
PARSE_OPT_ONE_SHOT = 32
31+
PARSE_OPT_KEEP_DASHDASH = 1 << 0,
32+
PARSE_OPT_STOP_AT_NON_OPTION = 1 << 1,
33+
PARSE_OPT_KEEP_ARGV0 = 1 << 2,
34+
PARSE_OPT_KEEP_UNKNOWN = 1 << 3,
35+
PARSE_OPT_NO_INTERNAL_HELP = 1 << 4,
36+
PARSE_OPT_ONE_SHOT = 1 << 5,
3737
};
3838

3939
enum parse_opt_option_flags {
40-
PARSE_OPT_OPTARG = 1,
41-
PARSE_OPT_NOARG = 2,
42-
PARSE_OPT_NONEG = 4,
43-
PARSE_OPT_HIDDEN = 8,
44-
PARSE_OPT_LASTARG_DEFAULT = 16,
45-
PARSE_OPT_NODASH = 32,
46-
PARSE_OPT_LITERAL_ARGHELP = 64,
47-
PARSE_OPT_SHELL_EVAL = 256,
48-
PARSE_OPT_NOCOMPLETE = 512,
49-
PARSE_OPT_COMP_ARG = 1024,
50-
PARSE_OPT_CMDMODE = 2048
40+
PARSE_OPT_OPTARG = 1 << 0,
41+
PARSE_OPT_NOARG = 1 << 1,
42+
PARSE_OPT_NONEG = 1 << 2,
43+
PARSE_OPT_HIDDEN = 1 << 3,
44+
PARSE_OPT_LASTARG_DEFAULT = 1 << 4,
45+
PARSE_OPT_NODASH = 1 << 5,
46+
PARSE_OPT_LITERAL_ARGHELP = 1 << 6,
47+
PARSE_OPT_SHELL_EVAL = 1 << 8,
48+
PARSE_OPT_NOCOMPLETE = 1 << 9,
49+
PARSE_OPT_COMP_ARG = 1 << 10,
50+
PARSE_OPT_CMDMODE = 1 << 11,
5151
};
5252

5353
enum parse_opt_result {

0 commit comments

Comments
 (0)