index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/alpm.h | 11 | ||||
-rw-r--r-- | lib/libalpm/be_local.c | 8 | ||||
-rw-r--r-- | lib/libalpm/be_sync.c | 5 | ||||
-rw-r--r-- | lib/libalpm/deps.c | 6 | ||||
-rw-r--r-- | lib/libalpm/package.c | 7 | ||||
-rw-r--r-- | lib/libalpm/package.h | 6 |
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index c94cdf7f..42e60385 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -60,6 +60,12 @@ typedef enum _alpm_pkgreason_t { ALPM_PKG_REASON_DEPEND = 1 } alpm_pkgreason_t; +typedef enum _alpm_pkgfrom_t { + PKG_FROM_FILE = 1, + PKG_FROM_LOCALDB, + PKG_FROM_SYNCDB +} alpm_pkgfrom_t; + /** Types of version constraints in dependency specs. */ typedef enum _alpm_depmod_t { /** No version constraint */ @@ -592,6 +598,11 @@ const char *alpm_pkg_get_name(alpm_pkg_t *pkg); */ const char *alpm_pkg_get_version(alpm_pkg_t *pkg); +/** Returns the origin of the package. + * @return a #alpm_pkgfrom_t constant, -1 on error + */ +alpm_pkgfrom_t alpm_pkg_get_origin(alpm_pkg_t *pkg); + /** Returns the package description. * @param pkg a pointer to package * @return a reference to an internal string diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 1a46dfdf..be02bb50 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -580,7 +580,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) goto error; } while(!feof(fp)) { - READ_NEXT(); + if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) { + goto error; + } + if(_alpm_strip_newline(line) == 0) { + /* length of stripped line was zero */ + continue; + } if(strcmp(line, "%NAME%") == 0) { READ_NEXT(); if(strcmp(line, info->name) != 0) { diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index ac99e05e..12d5b7fe 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -526,7 +526,10 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive, int ret; while((ret = _alpm_archive_fgets(archive, &buf)) == ARCHIVE_OK) { char *line = buf.line; - _alpm_strip_newline(line); + if(_alpm_strip_newline(line) == 0) { + /* length of stripped line was zero */ + continue; + } if(strcmp(line, "%NAME%") == 0) { READ_NEXT(); diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 47b7637a..e268157a 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -441,7 +441,11 @@ alpm_depend_t *_alpm_splitdep(const char *depstring) } /* copy the right parts to the right places */ - STRNDUP(depend->name, depstring, ptr - depstring, return NULL); + if(ptr) { + STRNDUP(depend->name, depstring, ptr - depstring, return NULL); + } else { + STRDUP(depend->name, depstring, return NULL); + } depend->name_hash = _alpm_hash_sdbm(depend->name); if(version) { STRDUP(depend->version, version, return NULL); diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 3d73a433..487b56d9 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -185,6 +185,13 @@ const char SYMEXPORT *alpm_pkg_get_version(alpm_pkg_t *pkg) return pkg->version; } +alpm_pkgfrom_t SYMEXPORT alpm_pkg_get_origin(alpm_pkg_t *pkg) +{ + ASSERT(pkg != NULL, return -1); + pkg->handle->pm_errno = 0; + return pkg->origin; +} + const char SYMEXPORT *alpm_pkg_get_desc(alpm_pkg_t *pkg) { ASSERT(pkg != NULL, return NULL); diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 707405dd..5962b1d0 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -34,12 +34,6 @@ #include "db.h" #include "signing.h" -typedef enum _alpm_pkgfrom_t { - PKG_FROM_FILE = 1, - PKG_FROM_LOCALDB, - PKG_FROM_SYNCDB -} alpm_pkgfrom_t; - /** Package operations struct. This struct contains function pointers to * all methods used to access data in a package to allow for things such * as lazy package intialization (such as used by the file backend). Each |