[pacman-dev] [PATCH 5/5] Split group handling into separate function

Jakob Gruber jakob.gruber at gmail.com
Sat Sep 25 05:40:06 EDT 2010


For improved readability.

Signed-off-by: Jakob Gruber <jakob.gruber at gmail.com>
---
 lib/libalpm/sync.c |   42 ++++++++++++++++++++++++------------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 8982874..8bd34b1 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -248,29 +248,13 @@ static int sync_pkg(pmpkg_t *spkg, alpm_list_t *pkg_list)
 	return(0);
 }
 
-static int sync_target(alpm_list_t *dbs_sync, const char *target)
-{
+static int sync_target(alpm_list_t *dbs_sync, const char *target);
+static int sync_group(alpm_list_t *dbs_sync, const char *target) {
 	alpm_list_t *i, *j;
 	alpm_list_t *known_pkgs = NULL;
-	pmpkg_t *spkg;
-	pmdepend_t *dep; /* provisions and dependencies are also allowed */
 	pmgrp_t *grp;
 	int found = 0;
 
-	ALPM_LOG_FUNC;
-
-	/* Sanity checks */
-	ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
-	ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
-
-	dep = _alpm_splitdep(target);
-	spkg = _alpm_resolvedep(dep, dbs_sync, NULL, 1);
-	_alpm_dep_free(dep);
-
-	if(spkg != NULL) {
-		return(sync_pkg(spkg, handle->trans->add));
-	}
-
 	/* begin group handling. this section is responsible for looking for
 	 * groups, user interaction, and finally adding group members to the
 	 * queue. to stay consistent with individual package handling, it
@@ -342,6 +326,28 @@ static int sync_target(alpm_list_t *dbs_sync, const char *target)
 	return(0);
 }
 
+static int sync_target(alpm_list_t *dbs_sync, const char *target)
+{
+	pmpkg_t *spkg;
+	pmdepend_t *dep; /* provisions and dependencies are also allowed */
+
+	ALPM_LOG_FUNC;
+
+	/* Sanity checks */
+	ASSERT(target != NULL && strlen(target) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+	ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
+
+	dep = _alpm_splitdep(target);
+	spkg = _alpm_resolvedep(dep, dbs_sync, NULL, 1);
+	_alpm_dep_free(dep);
+
+	if(spkg != NULL) {
+		return(sync_pkg(spkg, handle->trans->add));
+	}
+
+	return(sync_group(dbs_sync, target));
+}
+
 /** Add a sync target to the transaction.
  * @param target the name of the sync target to add
  * @return 0 on success, -1 on error (pm_errno is set accordingly)
-- 
1.7.3



More information about the pacman-dev mailing list