From 6c27794c5b3f86fc38d1f8287a7fd247c2c7c373 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 14 Jan 2010 13:39:17 +0100 Subject: [PATCH] xbps-bin: simplify pkgname_from_pkgmatch() and fix a bug. --HG-- extra : convert_revision : xtraeme%40gmail.com-20100114123917-3tvrb3tp097nnq8r --- bin/xbps-bin/install.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index 1ea35934..f98c1c0f 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -323,7 +323,6 @@ static char * pkgname_from_pkgmatch(const char *pkg) { const char *version; - char *pkgname = NULL; /* * Check if 'pkg' string is a pkgmatch valid pattern or it @@ -333,13 +332,12 @@ pkgname_from_pkgmatch(const char *pkg) */ if ((version = xbps_get_pkgdep_version(pkg))) { while (*version) { - if (isdigit((unsigned char)*version)) { + if (!isdigit((unsigned char)*version)) { version++; continue; } if (xbps_cmpver("0", version) <= 0) - pkgname = xbps_get_pkgdep_name(pkg); - break; + return xbps_get_pkgdep_name(pkg); } } if ((version = xbps_get_pkg_version(pkg))) { @@ -369,12 +367,11 @@ pkgname_from_pkgmatch(const char *pkg) break; if (xbps_cmpver("0", version) <= 0) - pkgname = xbps_get_pkg_name(pkg); - break; + return xbps_get_pkg_name(pkg); } } - return pkgname; + return NULL; } int