summaryrefslogtreecommitdiff
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2010-10-11 14:05:07 +1000
committerAllan McRae <allan@archlinux.org>2010-10-14 13:17:40 +1000
commite464339e3bd37e9bdb2c8d13fa29408a1123f620 (patch)
tree2bc900f94e9204625e15e0cb7d339892cbe26949 /lib/libalpm/db.c
parent448f78c067955d617c302f322a2dc6507cb6eb13 (diff)
downloadpacman-e464339e3bd37e9bdb2c8d13fa29408a1123f620.tar.xz
Move and rename splitname
The splitname function is a general utility function and so is better suited to util.h. Rename it to _alpm_splitname to indicate it is an internal libalpm function as was the case prior to splitting local and sync db handling. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index af68a508..79d20d49 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -750,50 +750,4 @@ pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target)
return(NULL);
}
-
-int splitname(const char *target, pmpkg_t *pkg)
-{
- /* the format of a db entry is as follows:
- * package-version-rel/
- * package name can contain hyphens, so parse from the back- go back
- * two hyphens and we have split the version from the name.
- */
- char *tmp, *p, *q;
-
- if(target == NULL || pkg == NULL) {
- return(-1);
- }
- STRDUP(tmp, target, RET_ERR(PM_ERR_MEMORY, -1));
- p = tmp + strlen(tmp);
-
- /* remove any trailing '/' */
- while (*(p - 1) == '/') {
- --p;
- *p = '\0';
- }
-
- /* do the magic parsing- find the beginning of the version string
- * by doing two iterations of same loop to lop off two hyphens */
- for(q = --p; *q && *q != '-'; q--);
- for(p = --q; *p && *p != '-'; p--);
- if(*p != '-' || p == tmp) {
- return(-1);
- }
-
- /* copy into fields and return */
- if(pkg->version) {
- FREE(pkg->version);
- }
- STRDUP(pkg->version, p+1, RET_ERR(PM_ERR_MEMORY, -1));
- /* insert a terminator at the end of the name (on hyphen)- then copy it */
- *p = '\0';
- if(pkg->name) {
- FREE(pkg->name);
- }
- STRDUP(pkg->name, tmp, RET_ERR(PM_ERR_MEMORY, -1));
-
- free(tmp);
- return(0);
-}
-
/* vim: set ts=2 sw=2 noet: */