index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | src/pacman/package.c | 7 | ||||
-rw-r--r-- | src/pacman/query.c | 9 | ||||
-rw-r--r-- | src/pacman/sync.c | 4 |
diff --git a/src/pacman/package.c b/src/pacman/package.c index 7019e7e6..76e8e4fd 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -225,17 +225,14 @@ void dump_pkg_files(pmpkg_t *pkg) { const char *pkgname, *root, *filestr; alpm_list_t *i, *pkgfiles; - char path[PATH_MAX]; pkgname = alpm_pkg_get_name(pkg); pkgfiles = alpm_pkg_get_files(pkg); root = alpm_option_get_root(); for(i = pkgfiles; i; i = alpm_list_next(i)) { - filestr = (char*)alpm_list_getdata(i); - /* build a path so we can stat the filename */ - snprintf(path, PATH_MAX-1, "%s%s", root, filestr); - fprintf(stdout, "%s %s\n", pkgname, path); + filestr = alpm_list_getdata(i); + fprintf(stdout, "%s %s%s\n", pkgname, root, filestr); } fflush(stdout); diff --git a/src/pacman/query.c b/src/pacman/query.c index b40359ed..0b6ce0c0 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -69,9 +69,8 @@ static int query_fileowner(alpm_list_t *targets) for(t = targets; t; t = alpm_list_next(t)) { int found = 0; char *filename = alpm_list_getdata(t); - char *bname; - char *dname; - char *rpath; + char *bname, *dname, *rpath; + const char *root; struct stat buf; alpm_list_t *i, *j; @@ -101,13 +100,15 @@ static int query_fileowner(alpm_list_t *targets) continue; } + root = alpm_option_get_root(); + for(i = alpm_db_getpkgcache(db_local); i && !found; i = alpm_list_next(i)) { pmpkg_t *info = alpm_list_getdata(i); for(j = alpm_pkg_get_files(info); j && !found; j = alpm_list_next(j)) { char path[PATH_MAX], *ppath, *pdname; snprintf(path, PATH_MAX, "%s%s", - alpm_option_get_root(), (const char *)alpm_list_getdata(j)); + root, (const char *)alpm_list_getdata(j)); /* avoid the costly resolve_path usage if the basenames don't match */ if(strcmp(mbasename(path), bname) != 0) { diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 77b66da5..3c6dfd58 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -57,7 +57,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) { struct stat buf; alpm_list_t *syncdbs = NULL, *i; int found = 0; - char *dname = ent->d_name; + const char *dname = ent->d_name; if(!strcmp(dname, ".") || !strcmp(dname, "..")) { continue; @@ -68,7 +68,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) { } /* build the full path */ - snprintf(path, PATH_MAX, "%s%s", dbpath, ent->d_name); + snprintf(path, PATH_MAX, "%s%s", dbpath, dname); /* skip entries that are not dirs (lock file, etc.) */ stat(path, &buf); if(!S_ISDIR(buf.st_mode)) { |