From 0c62b36c19d67939d7a84159c86a5de73fd9d36f Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 19 May 2012 23:36:30 +1000 Subject: Allow leading "local/" in query operations I find that when copying the output of "pacman -Qs foo" into a "pacman -Qi" operation to get more information on the packages, I consistently copy the "local/" prefix. It is a minor usability improvement to strip this if present. Dan: Pluck out LOCAL_PREFIX and magic numbers. Signed-off-by: Allan McRae --- src/pacman/query.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/query.c b/src/pacman/query.c index 08974105..9b1ea6f1 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -36,6 +36,8 @@ #include "conf.h" #include "util.h" +#define LOCAL_PREFIX "local/" + static char *resolve_path(const char *file) { char *str = NULL; @@ -268,7 +270,7 @@ static int query_search(alpm_list_t *targets) alpm_pkg_t *pkg = i->data; if(!config->quiet) { - printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); + printf(LOCAL_PREFIX "%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); } else { fputs(alpm_pkg_get_name(pkg), stdout); } @@ -556,6 +558,11 @@ int pacman_query(alpm_list_t *targets) for(i = targets; i; i = alpm_list_next(i)) { const char *strname = i->data; + /* strip leading part of "local/pkgname" */ + if(strncmp(strname, LOCAL_PREFIX, strlen(LOCAL_PREFIX)) == 0) { + strname += strlen(LOCAL_PREFIX); + } + if(config->op_q_isfile) { alpm_pkg_load(config->handle, strname, 1, 0, &pkg); } else { -- cgit v1.2.3-70-g09d2