Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   Reformat -Sg output to look like -Qg (http://www.linux-archive.org/archlinux-pacman-development/101696-reformat-sg-output-look-like-qg.html)

Dan McGee 06-06-2008 04:23 AM

Reformat -Sg output to look like -Qg
 
We used list_display() on -Sg output, which might have been slightly nicer
looking but made it much harder to parse in something like a shell script.
Reformat it in the 'grpname pkgname' format that -Qg is already using.

Signed-off-by: Dan McGee <dan@archlinux.org>
---
src/pacman/sync.c | 25 ++++++++++---------------
1 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 923394c..47ab4eb 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -346,25 +346,20 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
{
alpm_list_t *i, *j, *k;
- alpm_list_t *pkgnames = NULL;

if(targets) {
for(i = targets; i; i = alpm_list_next(i)) {
- char *grpname = alpm_list_getdata(i);
+ const char *grpname = alpm_list_getdata(i);
for(j = syncs; j; j = alpm_list_next(j)) {
pmdb_t *db = alpm_list_getdata(j);
pmgrp_t *grp = alpm_db_readgrp(db, grpname);

if(grp) {
- printf("%s
", alpm_grp_get_name(grp));
/* get names of packages in group */
for(k = alpm_grp_get_pkgs(grp); k; k = alpm_list_next(k)) {
- pkgnames = alpm_list_add(pkgnames,
- (char*)alpm_pkg_get_name(k->data));
+ printf("%s %s
", grpname,
+ alpm_pkg_get_name(alpm_list_getdata(k)));
}
- list_display(" ", pkgnames);
- alpm_list_free(pkgnames);
- pkgnames = NULL;
}
}
}
@@ -374,16 +369,16 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)

for(j = alpm_db_getgrpcache(db); j; j = alpm_list_next(j)) {
pmgrp_t *grp = alpm_list_getdata(j);
+ const char *grpname = alpm_grp_get_name(grp);

- printf("%s
", alpm_grp_get_name(grp));
- if(grp && level > 1) {
+ if(level > 1) {
for(k = alpm_grp_get_pkgs(grp); k; k = alpm_list_next(k)) {
- pkgnames = alpm_list_add(pkgnames,
- (char*)alpm_pkg_get_name(k->data));
+ printf("%s %s
", grpname,
+ alpm_pkg_get_name(alpm_list_getdata(k)));
}
- list_display(" ", pkgnames);
- alpm_list_free(pkgnames);
- pkgnames = NULL;
+ } else {
+ /* print grp names only, no package names */
+ printf("%s
", grpname);
}
}
}
--
1.5.5.3


_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev

Xavier 06-06-2008 08:55 AM

Reformat -Sg output to look like -Qg
 
On Fri, Jun 6, 2008 at 6:23 AM, Dan McGee <dan@archlinux.org> wrote:
> We used list_display() on -Sg output, which might have been slightly nicer
> looking but made it much harder to parse in something like a shell script.
> Reformat it in the 'grpname pkgname' format that -Qg is already using.
>
> Signed-off-by: Dan McGee <dan@archlinux.org>

Sounds good to me.
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev

Xavier 06-06-2008 12:13 PM

Reformat -Sg output to look like -Qg
 
Please ignore the attached file. I wanted to refactor the code a bit,
but I realized too late that it was not easy because of the level
handling (-Sg vs -Sgg), so I gave up, but I forgot to remove the
attachment...

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev


All times are GMT. The time now is 04:42 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.