about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--man/mpick.112
-rw-r--r--mpick.c20
2 files changed, 26 insertions, 6 deletions
diff --git a/man/mpick.1 b/man/mpick.1
index d845055..90c62dc 100644
--- a/man/mpick.1
+++ b/man/mpick.1
@@ -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
diff --git a/mpick.c b/mpick.c
index e99f9d5..1bbc44e 100644
--- a/mpick.c
+++ b/mpick.c
@@ -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;
 }