Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-02-01 06:35:30 +0000
committerDan McGee <dan@archlinux.org>2007-02-01 06:35:30 +0000
commitcdaed9221d9614c4c43103d79f8b53b916d80d86 (patch)
tree4a96afbd93f1e52f8a3104979f95d3ba76acce79
parent8c0a8ddc5bb6443358e1cbba8023b6e9dc786fca (diff)
* 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.
-rw-r--r--src/pacman/add.c3
-rw-r--r--src/pacman/remove.c3
-rw-r--r--src/pacman/sync.c14
-rw-r--r--src/pacman/util.c32
-rw-r--r--src/pacman/util.h1
5 files changed, 12 insertions, 41 deletions
diff --git a/src/pacman/add.c b/src/pacman/add.c
index 6572b8fc..74f9e27b 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -76,12 +76,13 @@ int pacman_add(alpm_list_t *targets)
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
*/
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 28f7411d..dba1d4e3 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -121,7 +121,8 @@ int pacman_remove(alpm_list_t *targets)
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) {
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 71545ebc..2384a721 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -292,6 +292,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
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 @@ int pacman_sync(alpm_list_t *targets)
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 @@ int pacman_sync(alpm_list_t *targets)
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) {
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 01d0e65c..7cff41b7 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -194,32 +194,6 @@ void indentprint(const char *str, unsigned int indent)
}
}
-/* 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 @@ void list_display(const char *title, alpm_list_t *list)
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");
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 098fa62f..37509788 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -52,7 +52,6 @@ unsigned int getcols();
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);