summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2005-03-28 15:41:27 +0000
committerJason Woodward2005-03-28 15:41:27 +0000
commita93826dd2c93e66d6131cb98ce46e299b3083974 (patch)
tree22fb62f4912133996afc45056afc7209bf25fc6a
parent5ce77950992c0df844d9892a1cb413557999d3aa (diff)
downloadslapt-get-a93826dd2c93e66d6131cb98ce46e299b3083974.tar.gz
added generate_suggestions() so that suggestions are properly detected after transaction has been created instead of checking multiple times if possible suggestions are present in the current transaction
-rw-r--r--ChangeLog3
-rw-r--r--src/transaction.c39
-rw-r--r--src/transaction.h2
3 files changed, 24 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index cb19c85..6759d93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
0.9.9j Mar 28, 2005
+ * added generate_suggestions() so that suggestions are properly detected
+ after transaction has been created instead of checking multiple times
+ if possible suggestions are present in the current transaction
* fixed ignoring suggestion when there was only one suggestion
* added copy_pkg() to package.[ch] instead of using memcpy() in the transaction
code, so free_transaction() calls free_pkg() making all usage of pkg_info_t
diff --git a/src/transaction.c b/src/transaction.c
index 074080c..81c7e73 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -69,32 +69,25 @@ int handle_transaction(const rc_config *global_config, transaction_t *tran){
}
/* show suggested pkgs */
+ generate_suggestions(tran);
if( tran->suggests->count > 0 ){
- unsigned int len = 0,real_count = 0;
+ unsigned int len = 0;
+ printf(_("Suggested packages:\n"));
+ printf(" ");
for(i = 0; i < tran->suggests->count; ++i){
/* don't show suggestion for something we already have in the transaction */
if( search_transaction(tran,tran->suggests->pkgs[i]) == 1 ) continue;
- ++real_count;
- }
- if( real_count > 0 ){
- printf(_("Suggested packages:\n"));
- printf(" ");
-
- for(i = 0; i < tran->suggests->count; ++i){
- /* don't show suggestion for something we already have in the transaction */
- if( search_transaction(tran,tran->suggests->pkgs[i]) == 1 ) continue;
-
- if( len + strlen(tran->suggests->pkgs[i]) + 1 < MAX_LINE_LEN ){
- printf("%s ",tran->suggests->pkgs[i]);
- len += strlen(tran->suggests->pkgs[i]) + 1;
- }else{
- printf("\n %s ",tran->suggests->pkgs[i]);
- len = strlen(tran->suggests->pkgs[i]) + 3;
- }
+
+ if( len + strlen(tran->suggests->pkgs[i]) + 1 < MAX_LINE_LEN ){
+ printf("%s ",tran->suggests->pkgs[i]);
+ len += strlen(tran->suggests->pkgs[i]) + 1;
+ }else{
+ printf("\n %s ",tran->suggests->pkgs[i]);
+ len = strlen(tran->suggests->pkgs[i]) + 3;
}
- printf("\n");
}
+ printf("\n");
}
@@ -330,7 +323,6 @@ void add_install_to_transaction(transaction_t *tran,pkg_info_t *pkg){
pkg
);
queue_add_install(tran->queue,tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count]);
- add_suggestion(tran,tran->install_pkgs->pkgs[tran->install_pkgs->pkg_count]);
++tran->install_pkgs->pkg_count;
}
@@ -796,3 +788,10 @@ static void queue_free(queue_t *t){
free(t);
}
+void generate_suggestions(transaction_t *tran){
+ unsigned int i;
+ for(i = 0;i < tran->install_pkgs->pkg_count; ++i){
+ add_suggestion(tran,tran->install_pkgs->pkgs[i]);
+ }
+}
+
diff --git a/src/transaction.h b/src/transaction.h
index 5f5e0ec..064116a 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -56,3 +56,5 @@ int add_deps_to_trans(const rc_config *global_config, transaction_t *tran, struc
/* check to see if a package is conflicted */
pkg_info_t *is_conflicted(transaction_t *tran, struct pkg_list *avail_pkgs, struct pkg_list *installed_pkgs, pkg_info_t *pkg);
+void generate_suggestions(transaction_t *tran);
+