mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:14:12 +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))
|
if (!parse_option(argc, argv, narg, option, &list))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mask = 0;
|
unsigned clear = 0;
|
||||||
while (*list) {
|
while (*list) {
|
||||||
if (*list == ',' || *list == ' ' || *list == '\t') {
|
if (*list == ',' || *list == ' ' || *list == '\t') {
|
||||||
++list;
|
++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 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 size_t len = (comma) ? comma - list : strlen(list);
|
||||||
const option_verb *scan = verbs;
|
const option_verb *scan = verbs;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!scan->verb)
|
if (!scan->verb)
|
||||||
failure("Unknown verb '%.*s', for option '==%s'\n", (int)len, list,
|
failure("Unknown verb '%.*s', for option '==%s'\n", (int)len, list,
|
||||||
option);
|
option);
|
||||||
if (strlen(scan->verb) == len && strncmp(list, scan->verb, len) == 0) {
|
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;
|
list += len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user