Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Implement the !~ operator (negated glob match) for query strings.
Dag-Erling Smørgrav committed 10 years ago
commit 6a87076631fe864c37c36464694228d688d1f09a
parent e5647e2
3 files changed +66 -25
modified docs/pkg-query.8
@@ -14,7 +14,7 @@
.\"
.\"     @(#)pkg.8
.\"
-
.Dd November 18, 2014
+
.Dd March 7, 2016
.Dt PKG-QUERY 8
.Os
.Sh NAME
@@ -304,16 +304,34 @@ above for what information is used.
.El
.Ss Operators
.Bl -tag -width F1
-
.It Cm ~
-
String glob pattern matching
-
.It Cm > Ns Op =
-
Integer comparison
-
.It Cm < Ns Op =
-
Integer comparison
-
.It Cm = Ns Op =
-
Integer or string equality comparison
-
.It Cm !=
-
Integer or string inequality comparison
+
.It Va var Cm ~ Ar glob
+
The string value of
+
.Va var
+
matches the given glob pattern.
+
.It Va var Cm !~ Ar glob
+
The string value of
+
.Va var
+
does not match the given glob pattern.
+
.It Va var Cm > Ns Oo = Oc Ar num
+
The numerical value of
+
.Va var
+
is greater than
+
.Op or equal to
+
the given number.
+
.It Va var Cm < Ns Oo = Oc Ar num
+
The numerical value of
+
.Va var
+
is less than
+
.Op or equal to
+
the given number.
+
.It Va var Cm = Ns Oo = Oc Ar num
+
The numerical value of
+
.Va var
+
is equal to the given number.
+
.It Va var Cm != Ar num
+
The numerical value of
+
.Va var
+
is not equal to the given number.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified docs/pkg-rquery.8
@@ -14,7 +14,7 @@
.\"
.\"     @(#)pkg.8
.\"
-
.Dd October 30, 2014
+
.Dd March 7, 2016
.Dt PKG-RQUERY 8
.Os
.Sh NAME
@@ -294,14 +294,34 @@ above for what information is used.
.El
.Ss Operators
.Bl -tag -width F1
-
.It Cm ~
-
String glob pattern matching
-
.It Cm > Ns Op =
-
Integer comparison
-
.It Cm > Ns Op =
-
Integer comparison
-
.It Cm = Ns Op =
-
Integer or string comparison
+
.It Va var Cm ~ Ar glob
+
The string value of
+
.Va var
+
matches the given glob pattern.
+
.It Va var Cm !~ Ar glob
+
The string value of
+
.Va var
+
does not match the given glob pattern.
+
.It Va var Cm > Ns Oo = Oc Ar num
+
The numerical value of
+
.Va var
+
is greater than
+
.Op or equal to
+
the given number.
+
.It Va var Cm < Ns Oo = Oc Ar num
+
The numerical value of
+
.Va var
+
is less than
+
.Op or equal to
+
the given number.
+
.It Va var Cm = Ns Oo = Oc Ar num
+
The numerical value of
+
.Va var
+
is equal to the given number.
+
.It Va var Cm != Ar num
+
The numerical value of
+
.Va var
+
is not equal to the given number.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
modified src/query.c
@@ -656,18 +656,21 @@ bad_option:
					sbuf_putc(sqlcond, str[0]);
				}
			} else if (str[0] == '!') {
-
				if (str[1] != '=') {
-
					fprintf(stderr, "expecting = after !\n");
+
				if (str[1] == '=') {
+
					sbuf_putc(sqlcond, str[0]);
+
					sbuf_putc(sqlcond, str[1]);
+
				} else if (str[1] == '~') {
+
					sbuf_cat(sqlcond, " NOT GLOB ");
+
				} else {
+
					fprintf(stderr, "expecting = or ~ after !\n");
					return (EPKG_FATAL);
				}
+
				str++;
				if (state == OPERATOR_STRING) {
					state = NEXT_IS_STRING;
				} else {
					state = NEXT_IS_INT;
				}
-
				sbuf_putc(sqlcond, str[0]);
-
				str++;
-
				sbuf_putc(sqlcond, str[0]);
			} else {
				fprintf(stderr, "an operator is expected, got %c\n", str[0]);
				return (EPKG_FATAL);