about summary refs log tree commit diff
path: root/lr.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-08-21 12:52:45 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-08-21 12:52:45 +0200
commit7e021f95ea19b01f52d177d23031b5ab9df09c16 (patch)
treefb9bf7f1f4336537cc291694c408f538fba15589 /lr.c
parentedb2abe085f47b35c9379ee6deccf9223cb95d21 (diff)
downloadlr-7e021f95ea19b01f52d177d23031b5ab9df09c16.tar.gz
lr-7e021f95ea19b01f52d177d23031b5ab9df09c16.tar.xz
lr-7e021f95ea19b01f52d177d23031b5ab9df09c16.zip
add strop negations
Diffstat (limited to 'lr.c')
-rw-r--r--lr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lr.c b/lr.c
index a92dcb8..00b6454 100644
--- a/lr.c
+++ b/lr.c
@@ -604,6 +604,7 @@ parse_strcmp()
 {
 	enum prop prop;
 	enum op op;
+	int negate = 0;
 
 	if (token("fstype"))
 		prop = PROP_FSTYPE;
@@ -636,6 +637,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("!=~") || 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);
 
@@ -661,6 +674,12 @@ parse_strcmp()
 			exit(2);
 		}
 
+		if (negate) {
+			struct expr *not = mkexpr(EXPR_NOT);
+			not->a.expr = e;
+			return not;
+		}
+
 		return e;
 	}