Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/be_local.c2
-rw-r--r--lib/libalpm/be_sync.c2
-rw-r--r--lib/libalpm/db.c46
-rw-r--r--lib/libalpm/db.h2
-rw-r--r--lib/libalpm/util.c45
-rw-r--r--lib/libalpm/util.h2
6 files changed, 49 insertions, 50 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index e97c0055..abf0af4e 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -393,7 +393,7 @@ int _alpm_local_db_populate(pmdb_t *db)
return(-1);
}
/* split the db entry name */
- if(splitname(name, pkg) != 0) {
+ if(_alpm_splitname(name, pkg) != 0) {
_alpm_log(PM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
name);
_alpm_pkg_free(pkg);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 0504ca63..2981178c 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -172,7 +172,7 @@ int _alpm_sync_db_populate(pmdb_t *db)
name = archive_entry_pathname(entry);
- if(splitname(name, pkg) != 0) {
+ if(_alpm_splitname(name, pkg) != 0) {
_alpm_log(PM_LOG_ERROR, _("invalid name for database entry '%s'\n"),
name);
_alpm_pkg_free(pkg);
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: */
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index d28ace62..0a120f99 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -100,8 +100,6 @@ void _alpm_db_free_grpcache(pmdb_t *db);
alpm_list_t *_alpm_db_get_grpcache(pmdb_t *db);
pmgrp_t *_alpm_db_get_grpfromcache(pmdb_t *db, const char *target);
-int splitname(const char *target, pmpkg_t *pkg);
-
#endif /* _ALPM_DB_H */
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 5bf4ef12..26612418 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -800,4 +800,49 @@ char *_alpm_archive_fgets(char *line, size_t size, struct archive *a)
return(line);
}
+int _alpm_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: */
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 35c4d288..75e2c45f 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -27,6 +27,7 @@
#include "config.h"
#include "alpm_list.h"
+#include "package.h" /* pmpkg_t */
#include <stdio.h>
#include <string.h>
@@ -76,6 +77,7 @@ const char *_alpm_filecache_setup(void);
int _alpm_lstat(const char *path, struct stat *buf);
int _alpm_test_md5sum(const char *filepath, const char *md5sum);
char *_alpm_archive_fgets(char *line, size_t size, struct archive *a);
+int _alpm_splitname(const char *target, pmpkg_t *pkg);
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);