FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 04-21-2008, 11:30 AM
Nagy Gabor
 
Default One liner alpm_pkg_find

>From 60e9d311b05f9d5e1d4d63476eb00ec85077e965 Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Date: Mon, 21 Apr 2008 13:29:01 +0200
Subject: [PATCH] One liner alpm_pkg_find

This patch kills some code duplication.
Note: There was a little confusion between alpm_list_remove's and alpm_list_find's compare functions.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
---
lib/libalpm/alpm_list.c | 2 +-
lib/libalpm/db.c | 2 +-
lib/libalpm/deps.c | 2 +-
lib/libalpm/package.c | 16 +---------------
4 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index ae54e19..ecfef25 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -577,7 +577,7 @@ void SYMEXPORT *alpm_list_find(const alpm_list_t *haystack, const void *needle,
{
const alpm_list_t *lp = haystack;
while(lp) {
- if(lp->data && fn(lp->data, needle) == 0) {
+ if(lp->data && fn(needle, lp->data) == 0) {
return(lp->data);
}
lp = lp->next;
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 6847415..c05f465 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -632,7 +632,7 @@ pmdb_t *_alpm_db_register_sync(const char *treename)
*
* @return "provision.name" == needle (as string)
*/
-int _alpm_prov_cmp(const void *provision, const void *needle)
+int _alpm_prov_cmp(const void *needle, const void *provision)
{
char *tmpptr;
char *provname = strdup(provision);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index cec69be..280f2c0 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -196,7 +196,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse)
}

/* Little helper function for alpm_list_find */
-static int satisfycmp(const void *pkg, const void *depend)
+static int satisfycmp(const void *depend, const void *pkg)
{
return(!alpm_depcmp((pmpkg_t*) pkg, (pmdepend_t*) depend));
}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 1ce0194..8c05c97 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -1108,22 +1108,8 @@ error:
*/
pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle)
{
- alpm_list_t *lp;
-
ALPM_LOG_FUNC;
-
- if(needle == NULL || haystack == NULL) {
- return(NULL);
- }
-
- for(lp = haystack; lp; lp = lp->next) {
- pmpkg_t *info = lp->data;
-
- if(info && strcmp(alpm_pkg_get_name(info), needle) == 0) {
- return(info);
- }
- }
- return(NULL);
+ return(alpm_list_find(haystack, needle, _alpm_pkgname_pkg_cmp));
}

/** Test if a package should be ignored.
--
1.5.3.8


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 04-24-2008, 07:55 PM
Xavier
 
Default One liner alpm_pkg_find

Nagy Gabor wrote:
>>From 60e9d311b05f9d5e1d4d63476eb00ec85077e965 Mon Sep 17 00:00:00 2001
> From: Nagy Gabor <ngaba@bibl.u-szeged.hu>
> Date: Mon, 21 Apr 2008 13:29:01 +0200
> Subject: [PATCH] One liner alpm_pkg_find
>
> This patch kills some code duplication.
> Note: There was a little confusion between alpm_list_remove's and alpm_list_find's compare functions.
>
> Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
> ---
> lib/libalpm/alpm_list.c | 2 +-
> lib/libalpm/db.c | 2 +-
> lib/libalpm/deps.c | 2 +-
> lib/libalpm/package.c | 16 +---------------
> 4 files changed, 4 insertions(+), 18 deletions(-)

That is great, but it looks to me like there are 2 distinct and
independent parts in that patch.
So if you want to split it, it would be ideal and could be applied
without modifications

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 07:15 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org