mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:24:13 +08:00
mdbx-test: add 'strikethrough' for bitmask-options.
This commit is contained in:
parent
111befb695
commit
6b5ada7b6e
@ -75,7 +75,7 @@ bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
||||
if (!parse_option(argc, argv, narg, option, &list))
|
||||
return false;
|
||||
|
||||
mask = 0;
|
||||
unsigned clear = 0;
|
||||
while (*list) {
|
||||
if (*list == ',' || *list == ' ' || *list == '\t') {
|
||||
++list;
|
||||
@ -83,14 +83,21 @@ bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
||||
}
|
||||
|
||||
const char *const comma = strchr(list, ',');
|
||||
const bool strikethrough = *list == '-' || *list == '~';
|
||||
if (strikethrough || *list == '+')
|
||||
++list;
|
||||
else
|
||||
mask = clear;
|
||||
const size_t len = (comma) ? comma - list : strlen(list);
|
||||
const option_verb *scan = verbs;
|
||||
|
||||
while (true) {
|
||||
if (!scan->verb)
|
||||
failure("Unknown verb '%.*s', for option '==%s'\n", (int)len, list,
|
||||
option);
|
||||
if (strlen(scan->verb) == len && strncmp(list, scan->verb, len) == 0) {
|
||||
mask |= scan->mask;
|
||||
mask = strikethrough ? mask & ~scan->mask : mask | scan->mask;
|
||||
clear = strikethrough ? clear & ~scan->mask : clear | scan->mask;
|
||||
list += len;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user