summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_files.c
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2006-11-14 07:58:42 +0000
committerAaron Griffin <aaron@archlinux.org>2006-11-14 07:58:42 +0000
commit4470e5ce011fef0c918b5c3d1d42ae333fb361ba (patch)
tree5ce8d77cc28f688d53fdea517434f6b1f4f10f10 /lib/libalpm/be_files.c
parent7e835366f15f98a1688e022a781483d5c5eeb114 (diff)
downloadpacman-4470e5ce011fef0c918b5c3d1d42ae333fb361ba.tar.xz
* Numerous mini valgrind fixes.
* Addition of hacky architecture check in the _splitname function * Removal of libfetch from the archlinux proper - it has been renamed to libdownload and can be found at http://phraktured.net/libdownload * Merge of _some_ of the Frugalware makepkg change - this may still be incomplete * Removal of libftp from cvs proper * PKGBUILD manpage now says 'PKGBUILD' instead of FrugalBuild (he he)
Diffstat (limited to 'lib/libalpm/be_files.c')
-rw-r--r--lib/libalpm/be_files.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 563f3216..8f81235f 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -163,7 +163,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
if(pkg == NULL) {
return(NULL);
}
- if(_alpm_pkg_splitname(ent->d_name, pkg->name, pkg->version) == -1) {
+ if(_alpm_pkg_splitname(ent->d_name, pkg->name, pkg->version, 0) == -1) {
_alpm_log(PM_LOG_ERROR, _("invalid name for dabatase entry '%s'"), ent->d_name);
return(NULL);
}
@@ -180,9 +180,8 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
struct stat buf;
char path[PATH_MAX+1];
char line[513];
- char *lang_tmp;
pmlist_t *tmplist;
- char *foo;
+ char *locale;
if(db == NULL) {
RET_ERR(PM_ERR_DB_NULL, -1);
@@ -225,30 +224,26 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
info->desc_localized = _alpm_list_add(info->desc_localized, strdup(line));
}
- if (setlocale(LC_ALL, "") == NULL) { /* To fix segfault when locale invalid */
+ if((locale = setlocale(LC_ALL, "")) == NULL) { /* To fix segfault when locale invalid */
setenv("LC_ALL", "C", 1);
+ locale = setlocale(LC_ALL, "");
}
- if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
- RET_ERR(PM_ERR_MEMORY, -1);
- }
- snprintf(lang_tmp, strlen(setlocale(LC_ALL, "")), "%s", setlocale(LC_ALL, ""));
if(info->desc_localized && !info->desc_localized->next) {
snprintf(info->desc, 512, "%s", (char*)info->desc_localized->data);
} else {
- for (tmplist = info->desc_localized; tmplist; tmplist = tmplist->next) {
- if (tmplist->data && strncmp(tmplist->data, lang_tmp, strlen(lang_tmp))) {
- snprintf(info->desc, 512, "%s", (char*)info->desc_localized->data);
- } else {
- foo = strdup(tmplist->data);
- snprintf(info->desc, 512, "%s", foo+strlen(lang_tmp)+1);
- FREE(foo);
- break;
+ for (tmplist = info->desc_localized; tmplist; tmplist = tmplist->next) {
+ if (tmplist->data && strncmp(tmplist->data, locale, strlen(locale))) {
+ strncpy(info->desc, (char *)info->desc_localized->data, sizeof(info->desc));
+ } else {
+ char *p = (char *)tmplist->data;
+ p += strlen(locale) + 1;
+ strncpy(info->desc, p, sizeof(info->desc));
+ break;
+ }
}
- }
}
_alpm_strtrim(info->desc);
- FREE(lang_tmp);
} else if(!strcmp(line, "%GROUPS%")) {
while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) {
info->groups = _alpm_list_add(info->groups, strdup(line));