[pacman-dev] pmdepend_t / pmdepmissing_t accessors
I found the accessors for these two types were rather odd. There were only accessors for pmdepmissing_t, but half of them were actually accessors for the pmdepend_t field in the pmdepmissing_t structure. I thought it would make more sense to have accessors for each fields, but I could be wrong, so I'll let you decide :)
From 8de572b00ee0a6a3fbf9cd115805bcb17910cf9a Mon Sep 17 00:00:00 2001 From: Chantry Xavier <shiningxc@gmail.com> Date: Mon, 16 Jul 2007 14:08:48 +0200 Subject: [PATCH] new pmdepend_t / pmdepmissing_t accessors.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com> --- lib/libalpm/alpm.h | 14 ++++++++------ lib/libalpm/deps.c | 30 +++++++++++++++--------------- src/pacman/add.c | 16 +++++++++------- src/pacman/deptest.c | 4 ++-- src/pacman/remove.c | 5 +++-- src/pacman/sync.c | 17 +++++++++-------- 6 files changed, 46 insertions(+), 40 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 8181f2e..62969a5 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -353,12 +353,14 @@ typedef enum _pmdeptype_t { pmdepend_t *alpm_splitdep(const char *depstring); int alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep); -const char *alpm_dep_get_target(pmdepmissing_t *miss); -pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss); -pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss); -const char *alpm_dep_get_name(pmdepmissing_t *miss); -const char *alpm_dep_get_version(pmdepmissing_t *miss); -const char *alpm_depend_get_name(pmdepend_t *dep); +const char *alpm_miss_get_target(pmdepmissing_t *miss); +pmdeptype_t alpm_miss_get_type(pmdepmissing_t *miss); +pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss); + + +pmdepmod_t alpm_dep_get_mod(pmdepend_t *dep); +const char *alpm_dep_get_name(pmdepend_t *dep); +const char *alpm_dep_get_version(pmdepend_t *dep); /* * File conflicts diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index fd0b2e5..30c505d 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -734,7 +734,7 @@ error: return(-1); } -const char SYMEXPORT *alpm_dep_get_target(pmdepmissing_t *miss) +const char SYMEXPORT *alpm_miss_get_target(pmdepmissing_t *miss) { ALPM_LOG_FUNC; @@ -745,7 +745,7 @@ const char SYMEXPORT *alpm_dep_get_target(pmdepmissing_t *miss) return miss->target; } -pmdeptype_t SYMEXPORT alpm_dep_get_type(pmdepmissing_t *miss) +pmdeptype_t SYMEXPORT alpm_miss_get_type(pmdepmissing_t *miss) { ALPM_LOG_FUNC; @@ -756,40 +756,40 @@ pmdeptype_t SYMEXPORT alpm_dep_get_type(pmdepmissing_t *miss) return miss->type; } -pmdepmod_t SYMEXPORT alpm_dep_get_mod(pmdepmissing_t *miss) +pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss) { ALPM_LOG_FUNC; /* Sanity checks */ - ASSERT(handle != NULL, return(-1)); - ASSERT(miss != NULL, return(-1)); + ASSERT(handle != NULL, return(NULL)); + ASSERT(miss != NULL, return(NULL)); - return miss->depend.mod; + return &miss->depend; } -const char SYMEXPORT *alpm_dep_get_name(pmdepmissing_t *miss) +pmdepmod_t SYMEXPORT alpm_dep_get_mod(pmdepend_t *dep) { ALPM_LOG_FUNC; /* Sanity checks */ - ASSERT(handle != NULL, return(NULL)); - ASSERT(miss != NULL, return(NULL)); + ASSERT(handle != NULL, return(-1)); + ASSERT(dep != NULL, return(-1)); - return miss->depend.name; + return dep->mod; } -const char SYMEXPORT *alpm_dep_get_version(pmdepmissing_t *miss) +const char SYMEXPORT *alpm_dep_get_name(pmdepend_t *dep) { ALPM_LOG_FUNC; /* Sanity checks */ ASSERT(handle != NULL, return(NULL)); - ASSERT(miss != NULL, return(NULL)); + ASSERT(dep != NULL, return(NULL)); - return miss->depend.version; + return dep->name; } -const char SYMEXPORT *alpm_depend_get_name(pmdepend_t *dep) +const char SYMEXPORT *alpm_dep_get_version(pmdepend_t *dep) { ALPM_LOG_FUNC; @@ -797,7 +797,7 @@ const char SYMEXPORT *alpm_depend_get_name(pmdepend_t *dep) ASSERT(handle != NULL, return(NULL)); ASSERT(dep != NULL, return(NULL)); - return dep->name; + return dep->version; } /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/add.c b/src/pacman/add.c index 71578f6..67633e9 100644 --- a/src/pacman/add.c +++ b/src/pacman/add.c @@ -136,23 +136,24 @@ int pacman_add(alpm_list_t *targets) case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); + pmdepend_t *dep = alpm_miss_get_dep(miss); /* TODO indicate if the error was a virtual package or not: * :: %s: requires %s, provided by %s */ - printf(_(":: %s: requires %s"), alpm_dep_get_target(miss), - alpm_dep_get_name(miss)); - switch(alpm_dep_get_mod(miss)) { + printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), + alpm_dep_get_name(dep)); + switch(alpm_dep_get_mod(dep)) { case PM_DEP_MOD_ANY: break; case PM_DEP_MOD_EQ: - printf("=%s", alpm_dep_get_version(miss)); + printf("=%s", alpm_dep_get_version(dep)); break; case PM_DEP_MOD_GE: - printf(">=%s", alpm_dep_get_version(miss)); + printf(">=%s", alpm_dep_get_version(dep)); break; case PM_DEP_MOD_LE: - printf("<=%s", alpm_dep_get_version(miss)); + printf("<=%s", alpm_dep_get_version(dep)); break; } printf("\n"); @@ -161,8 +162,9 @@ int pacman_add(alpm_list_t *targets) case PM_ERR_CONFLICTING_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); + pmdepend_t *dep = alpm_miss_get_dep(miss); printf(_(":: %s: conflicts with %s"), - alpm_dep_get_target(miss), alpm_dep_get_name(miss)); + alpm_miss_get_target(miss), alpm_dep_get_name(dep)); } break; case PM_ERR_FILE_CONFLICTS: diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 0f149b2..7f89f6d 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -56,13 +56,13 @@ int pacman_deptest(alpm_list_t *targets) dep = alpm_splitdep(target); pkg = alpm_db_get_pkg(alpm_option_get_localdb(), - alpm_depend_get_name(dep)); + alpm_dep_get_name(dep)); if(pkg && alpm_depcmp(pkg, dep)) { found = 1; } else { /* not found, can we find anything that provides this in the local DB? */ provides = alpm_db_whatprovides(alpm_option_get_localdb(), - alpm_depend_get_name(dep)); + alpm_dep_get_name(dep)); for(j = provides; j; j = alpm_list_next(j)) { pmpkg_t *pkg; pkg = alpm_list_getdata(j); diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 0b6b4ce..e60d3e8 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -128,8 +128,9 @@ int pacman_remove(alpm_list_t *targets) case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - printf(_(":: %s depends on %s\n"), alpm_dep_get_target(miss), - alpm_dep_get_name(miss)); + pmdepend_t *dep = alpm_miss_get_dep(miss); + printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), + alpm_dep_get_name(dep)); } alpm_list_free(data); break; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 7729370..800738d 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -650,19 +650,20 @@ int pacman_sync(alpm_list_t *targets) case PM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - printf(_(":: %s depends on %s\n"), alpm_dep_get_target(miss), - alpm_dep_get_name(miss)); - switch(alpm_dep_get_mod(miss)) { + pmdepend_t *dep = alpm_miss_get_dep(miss); + printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss), + alpm_dep_get_name(dep)); + switch(alpm_dep_get_mod(dep)) { case PM_DEP_MOD_ANY: break; case PM_DEP_MOD_EQ: - printf("=%s", alpm_dep_get_version(miss)); + printf("=%s", alpm_dep_get_version(dep)); break; case PM_DEP_MOD_GE: - printf(">=%s", alpm_dep_get_version(miss)); + printf(">=%s", alpm_dep_get_version(dep)); break; case PM_DEP_MOD_LE: - printf("<=%s", alpm_dep_get_version(miss)); + printf("<=%s", alpm_dep_get_version(dep)); break; } printf("\n"); @@ -671,9 +672,9 @@ int pacman_sync(alpm_list_t *targets) case PM_ERR_CONFLICTING_DEPS: for(i = data; i; i = alpm_list_next(i)) { pmdepmissing_t *miss = alpm_list_getdata(i); - + pmdepend_t *dep = alpm_miss_get_dep(miss); printf(_(":: %s: conflicts with %s"), - alpm_dep_get_target(miss), alpm_dep_get_name(miss)); + alpm_miss_get_target(miss), alpm_dep_get_name(dep)); } break; default: -- 1.5.2.2
On 7/16/07, Xavier <shiningxc@gmail.com> wrote:
I found the accessors for these two types were rather odd. There were only accessors for pmdepmissing_t, but half of them were actually accessors for the pmdepend_t field in the pmdepmissing_t structure. I thought it would make more sense to have accessors for each fields, but I could be wrong, so I'll let you decide :)
From 8de572b00ee0a6a3fbf9cd115805bcb17910cf9a Mon Sep 17 00:00:00 2001 From: Chantry Xavier <shiningxc@gmail.com> Date: Mon, 16 Jul 2007 14:08:48 +0200 Subject: [PATCH] new pmdepend_t / pmdepmissing_t accessors.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
This seems like as good of fix/cleanup as any until we get rid of some of these possibly extra unnecessary types. -Dan
On Mon, Jul 16, 2007 at 09:17:46AM -0400, Dan McGee wrote:
On 7/16/07, Xavier <shiningxc@gmail.com> wrote:
This seems like as good of fix/cleanup as any until we get rid of some of these possibly extra unnecessary types.
I don't know if there are unnecessary types, but they are certainly odd, especially that pmdepmissing type used for conflict. I was actually thinking about adding a pmdepconflict type or something, and then rename the current pmconflict to pmfileconflict for example. Or maybe find a cleaner way to combine the different types together (maybe just better names could help), if we want to avoid having too many of them. I don't really know what would be best..
participants (2)
-
Dan McGee
-
Xavier