From 170d63190a3cfb0c12ee9ddfe07b21f20825bd6f Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 24 Jan 2007 08:51:50 +0000 Subject: * Shuffled some of the alpm_list free funtions - still not perfect, but better * Added alpm_list_remove_node for single list node removal * Proper error checking/output for failed db_read/db_write (missing files) * Invalid packages (missing files) are now removed from the package cache * -Qs and -Ss output now look the same * config.rpath causes errors on one machine I had, so I added it to CVS * Fixed a "clobbered memory" issue when installing groups - only the outer list should be free'd, not the contained data --- src/pacman/add.c | 2 +- src/pacman/deptest.c | 4 ++-- src/pacman/log.c | 6 ++++-- src/pacman/query.c | 17 ++++++++++++----- src/pacman/remove.c | 2 +- src/pacman/sync.c | 11 +++++------ 6 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/pacman/add.c b/src/pacman/add.c index 1dedbafb..64e5264d 100644 --- a/src/pacman/add.c +++ b/src/pacman/add.c @@ -167,7 +167,7 @@ int pacman_add(alpm_list_t *targets) cleanup: if(data) { - alpm_list_free(data, NULL); + alpm_list_free(data); } if(alpm_trans_release() == -1) { ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index a46141db..e37f4791 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -130,7 +130,7 @@ int pacman_deptest(alpm_list_t *targets) } synctargs = alpm_list_add(synctargs, strdup(alpm_dep_get_name(miss))); } - alpm_list_free(data, NULL); + alpm_list_free(data); break; case PM_ERR_CONFLICTING_DEPS: /* we can't auto-resolve conflicts */ @@ -139,7 +139,7 @@ int pacman_deptest(alpm_list_t *targets) MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss)); } retval = 127; - alpm_list_free(data, NULL); + alpm_list_free(data); break; default: retval = 127; diff --git a/src/pacman/log.c b/src/pacman/log.c index 4685bd85..f139fb14 100644 --- a/src/pacman/log.c +++ b/src/pacman/log.c @@ -192,12 +192,14 @@ int yesno(char *fmt, ...) pch--; } *++pch = 0; - strtrim(response); + if(strlen(response) != 0) { + strtrim(response); + } /* User hits 'enter', forcing a newline here */ neednl = 0; - if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || !strlen(response)) { + if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || strlen(response) == 0) { return(1); } } diff --git a/src/pacman/query.c b/src/pacman/query.c index 4124f400..62e7ef10 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -98,16 +98,23 @@ int pacman_query(alpm_list_t *targets) return(1); } for(i = ret; i; i = alpm_list_next(i)) { + char *group = NULL; + alpm_list_t *grp; pmpkg_t *pkg = alpm_list_getdata(i); - printf("local/%s/%s %s\n ", - (char *)alpm_list_getdata(alpm_pkg_get_groups(pkg)), - alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg)); + printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); + + if((grp = alpm_pkg_get_groups(pkg)) != NULL) { + group = alpm_list_getdata(grp); + printf(" (%s)\n ", (char *)alpm_list_getdata(grp)); + } else { + printf("\n "); + } + indentprint(alpm_pkg_get_desc(pkg), 4); printf("\n"); } - alpm_list_free_outer(ret); + alpm_list_free(ret); return(0); } diff --git a/src/pacman/remove.c b/src/pacman/remove.c index b8dd1544..94ee66a2 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -103,7 +103,7 @@ int pacman_remove(alpm_list_t *targets) MSG(NL, _(":: %s is required by %s\n"), alpm_dep_get_target(miss), alpm_dep_get_name(miss)); } - alpm_list_free(data, NULL); + alpm_list_free(data); break; default: break; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 6288ac50..6b1cb432 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -265,7 +265,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) indentprint(alpm_pkg_get_desc(pkg), 4); printf("\n\n"); } - alpm_list_free_outer(ret); + alpm_list_free(ret); } else { for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) { pmpkg_t *pkg = alpm_list_getdata(j); @@ -375,7 +375,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) if(db == NULL) { ERR(NL, _("repository \"%s\" was not found.\n"),repo); - FREELISTPTR(ls); + alpm_list_free(ls); return(1); } @@ -395,7 +395,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) } if(targets) { - FREELISTPTR(ls); + alpm_list_free(ls); } return(0); @@ -541,7 +541,7 @@ int pacman_sync(alpm_list_t *targets) } } } - FREELIST(pkgs); + alpm_list_free(pkgs); } } if(!found) { @@ -756,8 +756,7 @@ int pacman_sync(alpm_list_t *targets) */ cleanup: if(data) { - alpm_list_free(data, NULL); - data = NULL; + alpm_list_free(data); } if(alpm_trans_release() == -1) { ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno)); -- cgit v1.2.3-54-g00ecf