[pacman-dev] [PATCH v4 2/2] Show group status during file search
morganamilo
morganamilo at gmail.com
Tue Sep 4 13:47:44 UTC 2018
When doing "pacman -Fs", show the "(groupname)"
message just like "pacman -Ss".
And refactor group printing to its own function.
Signed-off-by: morganamilo <morganamilo at gmail.com>
---
Fix style
src/pacman/files.c | 1 +
src/pacman/package.c | 34 +++++++++++++++++++---------------
src/pacman/package.h | 1 +
3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/pacman/files.c b/src/pacman/files.c
index 58cf8d3d..fa4170bd 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -162,6 +162,7 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) {
colstr->title, alpm_pkg_get_name(pkg),
colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor);
+ print_groups(pkg);
print_installed(db_local, pkg);
printf("\n");
diff --git a/src/pacman/package.c b/src/pacman/package.c
index e80c5953..639b1247 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -494,6 +494,25 @@ void print_installed(alpm_db_t *db_local, alpm_pkg_t *pkg)
}
}
+void print_groups(alpm_pkg_t *pkg)
+{
+ alpm_list_t *grp;
+ if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
+ const colstr_t *colstr = &config->colstr;
+ alpm_list_t *k;
+ printf(" %s(", colstr->groups);
+ for(k = grp; k; k = alpm_list_next(k)) {
+ const char *group = k->data;
+ fputs(group, stdout);
+ if(alpm_list_next(k)) {
+ /* only print a spacer if there are more groups */
+ putchar(' ');
+ }
+ }
+ printf(")%s", colstr->nocolor);
+ }
+}
+
/**
* Display the details of a search.
* @param db the database we're searching
@@ -526,7 +545,6 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status)
cols = getcols();
for(i = searchlist; i; i = alpm_list_next(i)) {
- alpm_list_t *grp;
alpm_pkg_t *pkg = i->data;
if(config->quiet) {
@@ -536,20 +554,7 @@ int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status)
colstr->title, alpm_pkg_get_name(pkg),
colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor);
- if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
- alpm_list_t *k;
- printf(" %s(", colstr->groups);
- for(k = grp; k; k = alpm_list_next(k)) {
- const char *group = k->data;
- fputs(group, stdout);
- if(alpm_list_next(k)) {
- /* only print a spacer if there are more groups */
- putchar(' ');
- }
- }
- printf(")%s", colstr->nocolor);
- }
-
+ print_groups(pkg);
if(show_status) {
print_installed(db_local, pkg);
}
diff --git a/src/pacman/package.h b/src/pacman/package.h
index 68c2a630..03e1afa0 100644
--- a/src/pacman/package.h
+++ b/src/pacman/package.h
@@ -29,6 +29,7 @@ void dump_pkg_files(alpm_pkg_t *pkg, int quiet);
void dump_pkg_changelog(alpm_pkg_t *pkg);
void print_installed(alpm_db_t *db_local, alpm_pkg_t *pkg);
+void print_groups(alpm_pkg_t *pkg);
int dump_pkg_search(alpm_db_t *db, alpm_list_t *targets, int show_status);
#endif /* PM_PACKAGE_H */
--
2.18.0
More information about the pacman-dev
mailing list