mpick: add negations

pull/77/head
Duncaen 7 years ago committed by Duncan Overbruck
parent 6a074d7451
commit 4e7a5c5ab6

@ -127,12 +127,12 @@ tests are given by the following EBNF:
<strprop> ::= from | subject | to
| <str> -- header name
<strop> ::= == | = -- string equality
| === -- case insensitive string equality
| ~~ -- glob (fnmatch)
| ~~~ -- case insensitive glob (fnmatch)
| =~ -- POSIX Extended Regular Expressions
| =~~ -- case insensitive POSIX Extended Regular Expressions
<strop> ::= == | = | != -- string (in)equality
| === | !=== -- case insensitive string (in)equality
| ~~ | !~~ -- glob (fnmatch)
| ~~~ | !~~~ -- case insensitive glob (fnmatch)
| =~ | !=~ | !~ -- POSIX Extended Regular Expressions
| =~~ | !=~~ -- case insensitive POSIX Extended Regular Expressions
<str> ::= " ([^"] | "")+ " -- use "" for a single " inside "
| $[A-Za-z0-9_]+ -- environment variable

@ -329,10 +329,12 @@ parse_strcmp()
{
enum prop prop;
enum op op;
int negate;
char *h;
h = 0;
prop = 0;
negate = 0;
if (token("from"))
prop = PROP_FROM;
@ -357,6 +359,18 @@ parse_strcmp()
op = EXPR_STREQ;
else if (token("="))
op = EXPR_STREQ;
else if (token("!~~~"))
negate = 1, op = EXPR_GLOBI;
else if (token("!~~"))
negate = 1, op = EXPR_GLOB;
else if (token("!=~~"))
negate = 1, op = EXPR_REGEXI;
else if (token("!=~"))
negate = 1, op = EXPR_REGEX;
else if (token("!==="))
negate = 1, op = EXPR_STREQI;
else if (token("!==") || token("!="))
negate = 1, op = EXPR_STREQ;
else
parse_error("invalid string operator at '%.15s'", pos);
@ -400,6 +414,12 @@ parse_strcmp()
exit(2);
}
if (negate) {
struct expr *not = mkexpr(EXPR_NOT);
not->a.expr = e;
return not;
}
return e;
}

Loading…
Cancel
Save