Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
s/pkg_list_is_empty/pkg_list_count/g
Baptiste Daroussin committed 13 years ago
commit 653c81c7d8520d7ab154f8f81b3688ddd978c2fb
parent aa8d4086bc47830b361ab6e737b91ec842a0f3b6
4 files changed +33 -32
modified libpkg/pkg.c
@@ -845,28 +845,29 @@ pkg_addshlib(struct pkg *pkg, const char *name)
}

int
-
pkg_list_is_empty(struct pkg *pkg, pkg_list list) {
+
pkg_list_count(struct pkg *pkg, pkg_list list)
+
{
	switch (list) {
	case PKG_DEPS:
-
		return ((HASH_COUNT(pkg->deps) == 0));
+
		return (HASH_COUNT(pkg->deps));
	case PKG_RDEPS:
-
		return ((HASH_COUNT(pkg->rdeps) == 0));
+
		return (HASH_COUNT(pkg->rdeps));
	case PKG_LICENSES:
-
		return ((HASH_COUNT(pkg->licenses) == 0));
+
		return (HASH_COUNT(pkg->licenses));
	case PKG_OPTIONS:
-
		return ((HASH_COUNT(pkg->options) == 0));
+
		return (HASH_COUNT(pkg->options));
	case PKG_CATEGORIES:
-
		return ((HASH_COUNT(pkg->categories) == 0));
+
		return (HASH_COUNT(pkg->categories));
	case PKG_FILES:
-
		return ((HASH_COUNT(pkg->files) == 0));
+
		return (HASH_COUNT(pkg->files));
	case PKG_DIRS:
-
		return ((HASH_COUNT(pkg->dirs) == 0));
+
		return (HASH_COUNT(pkg->dirs));
	case PKG_USERS:
-
		return ((HASH_COUNT(pkg->users) == 0));
+
		return (HASH_COUNT(pkg->users));
	case PKG_GROUPS:
-
		return ((HASH_COUNT(pkg->groups) == 0));
+
		return (HASH_COUNT(pkg->groups));
	case PKG_SHLIBS:
-
		return ((HASH_COUNT(pkg->shlibs) == 0));
+
		return (HASH_COUNT(pkg->shlibs));
	}
	
	return (0);
modified libpkg/pkg.h
@@ -399,7 +399,7 @@ int pkg_get2(struct pkg const *const, ...);
const char *pkg_name(struct pkg const *const pkg);
const char *pkg_version(struct pkg const *const pkg);

-
int pkg_list_is_empty(struct pkg *, pkg_list);
+
int pkg_list_count(struct pkg *, pkg_list);
/**
 * Iterates over the dependencies of the package.
 * @param dep Must be set to NULL for the first call.
modified pkg/query.c
@@ -152,34 +152,34 @@ format_str(struct pkg *pkg, struct sbuf *dest, const char *qstr, void *data)
				qstr++;
				switch (qstr[0]) {
				case 'd':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_DEPS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_DEPS) > 0);
					break;
				case 'r':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_RDEPS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_RDEPS) > 0);
					break;
				case 'C':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_CATEGORIES));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_CATEGORIES) > 0);
					break;
				case 'F':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_FILES));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_FILES) > 0);
					break;
				case 'O':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_OPTIONS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_OPTIONS) > 0);
					break;
				case 'D':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_DIRS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_DIRS) > 0);
					break;
				case 'L':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_LICENSES));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_LICENSES) > 0);
					break;
				case 'U':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_USERS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_USERS) > 0);
					break;
				case 'G':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_GROUPS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_GROUPS) > 0);
					break;
				case 'B':
-
					sbuf_printf(dest, "%d", !pkg_list_is_empty(pkg, PKG_SHLIBS));
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_SHLIBS) > 0);
					break;
				}
				break;
modified pkg/utils.c
@@ -308,7 +308,7 @@ print_info(struct pkg * const pkg, unsigned int options)
				printf("\n");
			break;
		case INFO_CATEGORIES:
-
			if (!pkg_list_is_empty(pkg, PKG_CATEGORIES)) {
+
			if (pkg_list_count(pkg, PKG_CATEGORIES) > 0) {
				if (print_tag)
					printf("%-15s: ", "Categories");
				if (pkg_categories(pkg, &cat) == EPKG_OK)
@@ -320,7 +320,7 @@ print_info(struct pkg * const pkg, unsigned int options)
				printf("\n");
			break;
		case INFO_LICENSES:
-
			if (!pkg_list_is_empty(pkg, PKG_LICENSES)) {
+
			if (pkg_list_count(pkg, PKG_LICENSES) > 0) {
				if (print_tag)
					printf("%-15s: ", "Licenses");
				if (pkg_licenses(pkg, &lic) == EPKG_OK)
@@ -350,7 +350,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			printf("%s\n", comment);
			break;
		case INFO_OPTIONS:
-
			if (!pkg_list_is_empty(pkg, PKG_OPTIONS)) {
+
			if (pkg_list_count(pkg, PKG_OPTIONS) > 0) {
				if (print_tag)
					printf("%-15s:\n", "Options");
				while (pkg_options(pkg, &option) == EPKG_OK)
@@ -361,7 +361,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			}
			break;
		case INFO_SHLIBS:
-
			if (!pkg_list_is_empty(pkg, PKG_SHLIBS)) {
+
			if (pkg_list_count(pkg, PKG_SHLIBS) > 0) {
				if (print_tag)
					printf("%-15s:\n", "Shared Libs");
				while (pkg_shlibs(pkg, &shlib) == EPKG_OK)
@@ -407,7 +407,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			}
			break;
		case INFO_DEPS:
-
			if (!pkg_list_is_empty(pkg, PKG_DEPS)) {
+
			if (pkg_list_count(pkg, PKG_DEPS) > 0) {
				if (print_tag)
					printf("%-15s:\n", "Depends on");
				while (pkg_deps(pkg, &dep) == EPKG_OK)
@@ -418,7 +418,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			}
			break;
		case INFO_RDEPS:
-
			if (!pkg_list_is_empty(pkg, PKG_RDEPS)) {
+
			if (pkg_list_count(pkg, PKG_RDEPS) > 0) {
				if (print_tag)
					printf("%-15s:\n", "Required by");
				while (pkg_rdeps(pkg, &dep) == EPKG_OK)
@@ -430,7 +430,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			break;
		case INFO_FILES: /* Installed pkgs only */
			if (pkg_type(pkg) != PKG_REMOTE &&
-
			    !pkg_list_is_empty(pkg, PKG_FILES)) {
+
			    pkg_list_count(pkg, PKG_FILES) > 0) {
				if (print_tag)
					printf("%-15s:\n", "Files");
				while (pkg_files(pkg, &file) == EPKG_OK)
@@ -441,7 +441,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			break;
		case INFO_DIRS:	/* Installed pkgs only */
			if (pkg_type(pkg) != PKG_REMOTE &&
-
			    !pkg_list_is_empty(pkg, PKG_DIRS)) {
+
			    pkg_list_count(pkg, PKG_DIRS) > 0) {
				if (print_tag)
					printf("%-15s:\n", "Directories");
				while (pkg_dirs(pkg, &dir) == EPKG_OK)
@@ -452,7 +452,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			break;
		case INFO_USERS: /* Installed pkgs only */
			if (pkg_type(pkg) != PKG_REMOTE &&
-
			    !pkg_list_is_empty(pkg, PKG_USERS)) {
+
			    pkg_list_count(pkg, PKG_USERS) > 0) {
				if (print_tag)
					printf("%-15s: ", "Users");
				if (pkg_users(pkg, &user) == EPKG_OK)
@@ -464,7 +464,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			break;
		case INFO_GROUPS: /* Installed pkgs only */
			if (pkg_type(pkg) != PKG_REMOTE &&
-
			    !pkg_list_is_empty(pkg, PKG_GROUPS)) {
+
			    pkg_list_count(pkg, PKG_GROUPS) > 0) {
				if (print_tag)
					printf("%-15s: ", "Groups");
				if (pkg_groups(pkg, &group) == EPKG_OK)