mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
util/debug: update parse_enable_string to deal with +all/-all
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29944>
This commit is contained in:
parent
4b1e3b8515
commit
bc523e8949
1 changed files with 23 additions and 21 deletions
|
|
@ -450,31 +450,33 @@ parse_enable_string(const char *debug,
|
|||
uint64_t flag = default_value;
|
||||
|
||||
if (debug != NULL) {
|
||||
for (; control->string != NULL; control++) {
|
||||
if (!strcmp(debug, "all")) {
|
||||
flag |= control->flag;
|
||||
const char *s = debug;
|
||||
unsigned n;
|
||||
|
||||
for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
|
||||
bool enable;
|
||||
if (s[0] == '+') {
|
||||
enable = true;
|
||||
s++; n--;
|
||||
} else if (s[0] == '-') {
|
||||
enable = false;
|
||||
s++; n--;
|
||||
} else {
|
||||
const char *s = debug;
|
||||
unsigned n;
|
||||
|
||||
for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
|
||||
bool enable;
|
||||
if (s[0] == '+') {
|
||||
enable = true;
|
||||
s++; n--;
|
||||
} else if (s[0] == '-') {
|
||||
enable = false;
|
||||
s++; n--;
|
||||
} else {
|
||||
enable = true;
|
||||
}
|
||||
if (strlen(control->string) == n &&
|
||||
!strncmp(control->string, s, n)) {
|
||||
enable = true;
|
||||
}
|
||||
if (!strncmp(s, "all", 3)) {
|
||||
if (enable)
|
||||
flag = ~0ull;
|
||||
else
|
||||
flag = 0;
|
||||
} else {
|
||||
for (const struct debug_control *c = control; c->string != NULL; c++) {
|
||||
if (strlen(c->string) == n &&
|
||||
!strncmp(c->string, s, n)) {
|
||||
if (enable)
|
||||
flag |= control->flag;
|
||||
flag |= c->flag;
|
||||
else
|
||||
flag &= ~control->flag;
|
||||
flag &= ~c->flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue