diff options
Diffstat (limited to 'src/pacman/query.c')
-rw-r--r-- | src/pacman/query.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c index e999a328..b40359ed 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -1,7 +1,7 @@ /* * query.c * - * Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org> + * Copyright (c) 2002-2008 by Judd Vinet <jvinet@zeroflux.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -119,8 +119,13 @@ static int query_fileowner(alpm_list_t *targets) free(pdname); 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)); + if (!config->quiet) { + printf(_("%s is owned by %s %s\n"), filename, + alpm_pkg_get_name(info), alpm_pkg_get_version(info)); + } else { + printf("%s %s\n", alpm_pkg_get_name(info), + alpm_pkg_get_version(info)); + } found = 1; } free(ppath); @@ -155,7 +160,6 @@ static int query_search(alpm_list_t *targets) } for(i = searchlist; i; i = alpm_list_next(i)) { - char *group = NULL; alpm_list_t *grp; pmpkg_t *pkg = alpm_list_getdata(i); @@ -176,8 +180,17 @@ static int query_search(alpm_list_t *targets) if (!config->quiet) { if((grp = alpm_pkg_get_groups(pkg)) != NULL) { - group = alpm_list_getdata(grp); - printf(" (%s)", (char *)alpm_list_getdata(grp)); + alpm_list_t *k; + printf(" ("); + for(k = grp; k; k = alpm_list_next(k)) { + const char *group = alpm_list_getdata(k); + printf("%s", group); + if(alpm_list_next(k)) { + /* only print a spacer if there are more groups */ + printf(" "); + } + } + printf(")"); } /* we need a newline and initial indent first */ @@ -197,33 +210,33 @@ static int query_search(alpm_list_t *targets) static int query_group(alpm_list_t *targets) { alpm_list_t *i, *j; - char *package = NULL; + char *grpname = NULL; int ret = 0; if(targets == NULL) { for(j = alpm_db_getgrpcache(db_local); j; j = alpm_list_next(j)) { pmgrp_t *grp = alpm_list_getdata(j); - const alpm_list_t *p, *pkgnames; + const alpm_list_t *p, *packages; const char *grpname; grpname = alpm_grp_get_name(grp); - pkgnames = alpm_grp_get_pkgs(grp); + packages = alpm_grp_get_pkgs(grp); - for(p = pkgnames; p; p = alpm_list_next(p)) { - printf("%s %s\n", grpname, (char *)alpm_list_getdata(p)); + for(p = packages; p; p = alpm_list_next(p)) { + printf("%s %s\n", grpname, alpm_pkg_get_name(alpm_list_getdata(p))); } } } else { for(i = targets; i; i = alpm_list_next(i)) { pmgrp_t *grp; - package = alpm_list_getdata(i); - grp = alpm_db_readgrp(db_local, package); + grpname = alpm_list_getdata(i); + grp = alpm_db_readgrp(db_local, grpname); if(grp) { - const alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp); - for(p = pkgnames; p; p = alpm_list_next(p)) { - printf("%s %s\n", package, (char *)alpm_list_getdata(p)); + const alpm_list_t *p, *packages = alpm_grp_get_pkgs(grp); + for(p = packages; p; p = alpm_list_next(p)) { + printf("%s %s\n", grpname, alpm_pkg_get_name(alpm_list_getdata(p))); } } else { - fprintf(stderr, _("error: group \"%s\" was not found\n"), package); + fprintf(stderr, _("error: group \"%s\" was not found\n"), grpname); ret++; } } |