X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=config-set.c;h=5f654f7aff1cfa4cdbe5400d328363d4a91d490c;hb=936a23420c8e1630e013578ba9285cd69cf918f7;hp=90a28b381ff8bb25e148f3e81f9a57a46ab0c962;hpb=4ddba79db76bd6425f00e99ceb1d82d179319aec;p=git.git diff --git a/config-set.c b/config-set.c index 90a28b38..5f654f7a 100644 --- a/config-set.c +++ b/config-set.c @@ -8,13 +8,15 @@ static char* key = NULL; static char* value = NULL; static regex_t* regex = NULL; static int do_all = 0; +static int do_not_match = 0; static int seen = 0; static int show_config(const char* key_, const char* value_) { if (!strcmp(key_, key) && (regex == NULL || - !regexec(regex, value_, 0, NULL, 0))) { + (do_not_match ^ + !regexec(regex, value_, 0, NULL, 0)))) { if (do_all) { printf("%s\n", value_); return 0; @@ -38,6 +40,11 @@ static int get_value(const char* key_, const char* regex_) key[i] = tolower(key_[i]); if (regex_) { + if (regex_[0] == '!') { + do_not_match = 1; + regex_++; + } + regex = (regex_t*)malloc(sizeof(regex_t)); if (regcomp(regex, regex_, REG_EXTENDED)) { fprintf(stderr, "Invalid pattern: %s\n", regex_);