[pacman-dev] CVS update of pacman-lib/src/pacman (5 files)
Date: Thursday, February 1, 2007 @ 01:35:30 Author: dan Path: /home/cvs-pacman/pacman-lib/src/pacman Modified: add.c (1.27 -> 1.28) remove.c (1.27 -> 1.28) sync.c (1.105 -> 1.106) util.c (1.24 -> 1.25) util.h (1.13 -> 1.14) * Tried to clean up newline display a bit in the frontend. * Removed useless buildstring function from util.h; replaced all calls of it with list_display. * Made list_display output 2 spaces instead of 1 between each item. ----------+ add.c | 3 ++- remove.c | 3 ++- sync.c | 14 +++++--------- util.c | 32 +++----------------------------- util.h | 1 - 5 files changed, 12 insertions(+), 41 deletions(-) Index: pacman-lib/src/pacman/add.c diff -u pacman-lib/src/pacman/add.c:1.27 pacman-lib/src/pacman/add.c:1.28 --- pacman-lib/src/pacman/add.c:1.27 Wed Jan 31 01:10:22 2007 +++ pacman-lib/src/pacman/add.c Thu Feb 1 01:35:30 2007 @@ -76,12 +76,13 @@ MSG(NL, _("loading package data... ")); for(i = targets; i; i = i->next) { if(alpm_trans_addtarget(i->data) == -1) { + MSG(NL, "\n"); ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno)); retval = 1; goto cleanup; } } - MSG(CL, _("done.")); + MSG(CL, _("done.\n")); /* Step 2: "compute" the transaction based on targets and flags */ Index: pacman-lib/src/pacman/remove.c diff -u pacman-lib/src/pacman/remove.c:1.27 pacman-lib/src/pacman/remove.c:1.28 --- pacman-lib/src/pacman/remove.c:1.27 Wed Jan 31 01:10:22 2007 +++ pacman-lib/src/pacman/remove.c Thu Feb 1 01:35:30 2007 @@ -121,7 +121,8 @@ pmpkg_t *pkg = alpm_list_getdata(i); lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg))); } - list_display(_("\nTargets:"), lst); + MSG(NL, "\n"); + list_display(_("Targets:"), lst); FREELIST(lst); /* get confirmation */ if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) { Index: pacman-lib/src/pacman/sync.c diff -u pacman-lib/src/pacman/sync.c:1.105 pacman-lib/src/pacman/sync.c:1.106 --- pacman-lib/src/pacman/sync.c:1.105 Wed Jan 31 03:30:15 2007 +++ pacman-lib/src/pacman/sync.c Thu Feb 1 01:35:30 2007 @@ -292,6 +292,7 @@ pmgrp_t *grp = alpm_db_readgrp(db, grpname); if(grp) { + /* TODO this should be a lot cleaner, why two outputs? */ MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp)); list_display(" ", alpm_grp_get_packages(grp)); } @@ -659,12 +660,9 @@ list_install = alpm_list_add(list_install, str); } if(list_remove) { - MSG(NL, _("\nRemove: ")); - str = buildstring(list_remove); - indentprint(str, 9); - MSG(CL, "\n"); + MSG(NL, "\n"); /* TODO ugly hack. printing a single NL should be easy */ + list_display(_("Remove:"), list_remove); FREELIST(list_remove); - FREE(str); } mb = (double)(totalsize / 1048576.0); umb = (double)(totalisize / 1048576.0); @@ -675,15 +673,13 @@ if(umb > 0 && umb < 0.1) { umb = 0.1; } - MSG(NL, _("\nTargets: ")); - str = buildstring(list_install); - indentprint(str, 9); + MSG(NL, "\n"); + list_display(_("Targets:"), list_install); MSG(NL, _("\nTotal Package Size: %.1f MB\n"), mb); if(umb > 0) { MSG(NL, _("Total Installed Size: %.1f MB\n"), umb); } FREELIST(list_install); - FREE(str); if(config->op_s_downloadonly) { if(config->noconfirm) { Index: pacman-lib/src/pacman/util.c diff -u pacman-lib/src/pacman/util.c:1.24 pacman-lib/src/pacman/util.c:1.25 --- pacman-lib/src/pacman/util.c:1.24 Thu Jan 25 21:13:16 2007 +++ pacman-lib/src/pacman/util.c Thu Feb 1 01:35:30 2007 @@ -194,32 +194,6 @@ } } -/* Condense a list of strings into one long (space-delimited) string - */ -char *buildstring(alpm_list_t *strlist) -{ - char *str; - size_t size = 1; - alpm_list_t *i; - - for(i = strlist; i; i = alpm_list_next(i)) { - size += strlen(alpm_list_getdata(i)) + 1; - } - str = (char *)malloc(size); - if(str == NULL) { - ERR(NL, _("failed to allocate %d bytes\n"), size); - } - str[0] = '\0'; - for(i = strlist; i; i = alpm_list_next(i)) { - strcat(str, alpm_list_getdata(i)); - strcat(str, " "); - } - /* shave off the last space */ - str[strlen(str)-1] = '\0'; - - return(str); -} - /* Convert a string to uppercase */ char *strtoupper(char *str) @@ -265,17 +239,17 @@ if(list) { for(i = list, cols = len; i; i = alpm_list_next(i)) { char *str = alpm_list_getdata(i); - int s = strlen(str)+1; + int s = strlen(str) + 2; unsigned int maxcols = getcols(); if(s + cols >= maxcols) { int i; cols = len; printf("\n"); - for (i = 0; i < len+1; ++i) { + for (i = 0; i <= len; ++i) { printf(" "); } } - printf("%s ", str); + printf("%s ", str); cols += s; } printf("\n"); Index: pacman-lib/src/pacman/util.h diff -u pacman-lib/src/pacman/util.h:1.13 pacman-lib/src/pacman/util.h:1.14 --- pacman-lib/src/pacman/util.h:1.13 Fri Jan 19 04:28:47 2007 +++ pacman-lib/src/pacman/util.h Thu Feb 1 01:35:30 2007 @@ -52,7 +52,6 @@ int makepath(char *path); int rmrf(char *path); void indentprint(const char *str, unsigned int indent); -char *buildstring(alpm_list_t *strlist); char *strtoupper(char *str); char *strtrim(char *str); int reg_match(char *string, char *pattern);
participants (1)
-
dan@archlinux.org