diff options
author | Aaron Griffin <aaronmgriffin@gmail.com> | 2007-05-18 08:20:49 +0200 |
---|---|---|
committer | Aaron Griffin <aaronmgriffin@gmail.com> | 2007-05-18 08:20:49 +0200 |
commit | 1ef27e97a1a880288ba85cf45119e0074ff372eb (patch) | |
tree | 2e0415236087a87668210426ce8f0784407be2d7 | |
parent | 9d9ac66bb26df7ace59d5c441679a6f2a17d116d (diff) | |
download | pacman-1ef27e97a1a880288ba85cf45119e0074ff372eb.tar.gz pacman-1ef27e97a1a880288ba85cf45119e0074ff372eb.tar.xz |
Fix broken resolve_path function
Removed some unneeded path munging so that our relative
paths resolve properly. This closes FS#7068
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
-rw-r--r-- | src/pacman/query.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c index bb4cfb9d..06d111b0 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -43,32 +43,18 @@ extern pmdb_t *db_local; static char *resolve_path(const char* file) { - char *copy, *p, *str = NULL; + char *str = NULL; - if(!(copy = strdup(file))) { + str = calloc(PATH_MAX+1, sizeof(char)); + if(!str) { + /* null hmmm.... */ return(NULL); } - if((p = strrchr(copy, '/')) == NULL) { - return(copy); - } else { - *p = '\0'; ++p; - - str = calloc(PATH_MAX+1, sizeof(char)); - if(!str) { - /* null hmmm.... */ - return(NULL); - } - - if(!realpath(copy, str)) { - return(NULL); - } - - str[strlen(str)] = '/'; - strcat(str, p); + if(!realpath(copy, str)) { + return(NULL); } - free(copy); return(str); } @@ -115,7 +101,7 @@ static void query_fileowner(pmdb_t *db, char *filename) ppath = resolve_path(path); if(ppath && strcmp(ppath, rpath) == 0) { - printf(_("%s is owned by %s %s\n"), filename, alpm_pkg_get_name(info), alpm_pkg_get_version(info)); + printf(_("%s is owned by %s %s\n"), rpath, alpm_pkg_get_name(info), alpm_pkg_get_version(info)); found = 1; } |