Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Small simplification of the empty pattern case
Stefan Eßer committed 4 years ago
commit 7456d48848c68d0df784b7477fa08f7464ff2167
parent b58a6a6
1 file changed +5 -3
modified libpkg/repo/binary/query.c
@@ -115,11 +115,13 @@ pkg_repo_binary_query(struct pkg_repo *repo, const char *cond, const char *patte
		return (NULL);

	comp = pkgdb_get_pattern_query(pattern, match);
+
	if (comp == NULL)
+
		comp = "";
	if (cond == NULL)
-
		xasprintf(&sql, basesql, repo->name, comp ? comp : "", "", "", "");
+
		xasprintf(&sql, basesql, repo->name, comp, "", "", "");
	else
-
		xasprintf(&sql, basesql, repo->name, comp ? comp : "",
-
		    comp[0] ? "AND (" : "WHERE (", cond + 7, ")");
+
		xasprintf(&sql, basesql, repo->name, comp,
+
		    comp[0] != '\0' ? "AND (" : "WHERE (", cond + 7, ")");

	pkg_debug(4, "Pkgdb: running '%s' query for %s", sql,
	     pattern == NULL ? "all": pattern);