Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
fix to match more exactly. This makes 'print/cups' not to match 'print/cups-base'.
Yuichiro NAITO committed 6 years ago
commit 292e2fbd2a8e48051271ebe3a7007aa36dce7cf3
parent ffa76c0
2 files changed +52 -20
modified src/updating.c
@@ -124,12 +124,6 @@ matcher(const char *affects, const char *origin, bool ignorecase)
	struct regex_cache *ent;
	static SLIST_HEAD(,regex_cache) cache = SLIST_HEAD_INITIALIZER(regex_cache);

-
	if (strpbrk(affects,"^.$*|+?") == NULL &&
-
		(strchr(affects,'[') == NULL || strchr(affects,']') == NULL) &&
-
		(strchr(affects,'{') == NULL || strchr(affects,'}') == NULL) &&
-
		(strchr(affects,'(') == NULL || strchr(affects,')') == NULL))
-
		return 0;
-

	len = strlen(affects);
	buf = strdup(affects);
	if (buf == NULL)
@@ -167,15 +161,28 @@ matcher(const char *affects, const char *origin, bool ignorecase)
	}

	for(ret = 0, i = 0; i < count; i++) {
+
		n = strlen(words[i]);
+
		if (words[i][n-1] == ',') {
+
			words[i][n-1] = '\0';
+
		}
		if (strpbrk(words[i],"^$*|?") == NULL &&
			(strchr(words[i],'[') == NULL || strchr(words[i],']') == NULL) &&
			(strchr(words[i],'{') == NULL || strchr(words[i],'}') == NULL) &&
-
			(strchr(words[i],'(') == NULL || strchr(words[i],')') == NULL))
+
			(strchr(words[i],'(') == NULL || strchr(words[i],')') == NULL)) {
+
			if (ignorecase) {
+
				if (strcasecmp(words[i], origin) == 0) {
+
					ret = 1;
+
					break;
+
				}
+
			} else {
+
				if (strcmp(words[i], origin) == 0) {
+
					ret = 1;
+
					break;
+
				}
+
			}
			continue;
-
		n = strlen(words[i]);
-
		if (words[i][n-1] == ',') {
-
			words[i][n-1] = '\0';
		}
+

		found = 0;
		SLIST_FOREACH(ent, &cache, next) {
			if (ignorecase)
@@ -353,15 +360,6 @@ exec_updating(int argc, char **argv)
		if (found == 0) {
			if (strstr(line, "AFFECTS") != NULL) {
				SLIST_FOREACH(port, &origins, next) {
-
					if (caseinsensitive) {
-
						if ((tmp = strcasestr(line, port->origin)) != NULL) {
-
							break;
-
						}
-
					} else {
-
						if ((tmp = strstr(line, port->origin)) != NULL) {
-
							break;
-
						}
-
					}
					if (matcher(line, port->origin, caseinsensitive) != 0) {
						tmp = "";
						break;
modified tests/frontend/updating.sh
@@ -10,7 +10,8 @@ tests_init \
        updating_ilmbase \
        updating_mysql \
        updating_postgresql \
-
        updating_cupsbase
+
        updating_cupsbase \
+
        updating_cups \

updating_all_users_body() {
	cat > UPDATING <<EOF
@@ -262,3 +263,36 @@ EOF
		-o match:"^20190628:$" \
		pkg updating -f UPDATING
}
+

+
updating_cups_body() {
+
	cat > test.ucl << EOF
+
name: "cups"
+
origin: "print/cups"
+
version: "2.2.1"
+
arch: "*"
+
maintainer: "none"
+
prefix: "/usr/local"
+
www: "unknown"
+
comment: "need one"
+
desc: "also need one"
+
message: [
+
	{ message: "Always print" }
+
]
+
EOF
+
	atf_check \
+
		-o match:".*Installing.*" \
+
		pkg register -M test.ucl
+

+
	cat > UPDATING <<EOF
+
20190628:
+
  AFFECTS: users of print/cups-{base,client,image}
+
  AUTHOR: ports@FreeBSD.org
+

+
  Messages...
+
EOF
+

+
	atf_check \
+
		-o empty \
+
		-e empty \
+
		pkg updating -f UPDATING
+
}