[pacman-dev] CVS update of pacman-lib/src/pacman (downloadprog.c query.c)

Aaron Griffin aaron at archlinux.org
Wed Feb 7 00:25:45 EST 2007


    Date: Wednesday, February 7, 2007 @ 00:25:45
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib/src/pacman

Modified: downloadprog.c (1.11 -> 1.12) query.c (1.23 -> 1.24)

* Fix total transfered size on download bar
* Fix -Qm segfault
* Minor query cleanup


----------------+
 downloadprog.c |    2 -
 query.c        |   79 +++++++++++++++++++++++--------------------------------
 2 files changed, 35 insertions(+), 46 deletions(-)


Index: pacman-lib/src/pacman/downloadprog.c
diff -u pacman-lib/src/pacman/downloadprog.c:1.11 pacman-lib/src/pacman/downloadprog.c:1.12
--- pacman-lib/src/pacman/downloadprog.c:1.11	Tue Feb  6 22:15:18 2007
+++ pacman-lib/src/pacman/downloadprog.c	Wed Feb  7 00:25:45 2007
@@ -147,7 +147,7 @@
 	}
 
 	printf(" %-*s %6d%c %#6.1f%c/s %02u:%02u:%02u", FILENAME_TRIM_LEN, fname, 
-				 xfered/1024, xfered_size, rate, rate_size, eta_h, eta_m, eta_s);
+				 xfered, xfered_size, rate, rate_size, eta_h, eta_m, eta_s);
 
 	free(fname);
 	
Index: pacman-lib/src/pacman/query.c
diff -u pacman-lib/src/pacman/query.c:1.23 pacman-lib/src/pacman/query.c:1.24
--- pacman-lib/src/pacman/query.c:1.23	Tue Feb  6 17:36:14 2007
+++ pacman-lib/src/pacman/query.c	Wed Feb  7 00:25:45 2007
@@ -81,7 +81,7 @@
 
 int pacman_query(alpm_list_t *targets)
 {
-	alpm_list_t *sync_dbs = NULL, *i, *j;;
+	alpm_list_t *sync_dbs = NULL, *i, *j, *k;
 	pmpkg_t *info = NULL;
 	char *package = NULL;
 	int done = 0;
@@ -224,69 +224,58 @@
 					if(info == NULL) {
 						/* something weird happened */
 						ERR(NL, _("package \"%s\" not found\n"), pkgname);
-						/* do not return on query operations - let's just carry on */
-						/*return(1);*/
 						continue;
 					}
-					if(config->op_q_foreign) {
-						int match = 0;
-						for(i = sync_dbs; i; i = alpm_list_next(i)) {
-							pmdb_t *db = (pmdb_t *)alpm_list_getdata(i);
-							for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
-								pmpkg_t *pkg = alpm_list_getdata(j);
-								if(strcmp(alpm_pkg_get_name(pkg), alpm_pkg_get_name(info)) == 0) {
-									match = 1;
-								}
+				}
+				if(config->op_q_foreign) {
+					int match = 0;
+					for(j = sync_dbs; j; j = alpm_list_next(j)) {
+						pmdb_t *db = (pmdb_t *)alpm_list_getdata(j);
+						for(k = alpm_db_getpkgcache(db); k; k = alpm_list_next(k)) {
+							pmpkg_t *pkg = alpm_list_getdata(k);
+							if(strcmp(alpm_pkg_get_name(pkg), alpm_pkg_get_name(info)) == 0) {
+								match = 1;
 							}
 						}
-						if(match==0) {
-							MSG(NL, "%s %s\n", pkgname, pkgver);
-						}
 					}
-					if(config->op_q_list) {
-						dump_pkg_files(info);
+					if(match==0) {
+						MSG(NL, "%s %s\n", pkgname, pkgver);
+					}
+				} else if(config->op_q_list) {
+					dump_pkg_files(info);
+				} else if(config->op_q_orphans) {
+					if(alpm_pkg_get_requiredby(info) == NULL
+						 && (long)alpm_pkg_get_reason(info) == PM_PKG_REASON_DEPEND) {
+						MSG(NL, "%s %s\n", pkgname, pkgver);
 					}
-					if(config->op_q_orphans) {
-						if(alpm_pkg_get_requiredby(info) == NULL
-						   && (long)alpm_pkg_get_reason(info) == PM_PKG_REASON_DEPEND) {
-							MSG(NL, "%s %s\n", pkgname, pkgver);
-						}
-					} 
 				} else {
 					MSG(NL, "%s %s\n", pkgname, pkgver);
 				}
 			}
 		} else {
-
 			info = alpm_db_readpkg(db_local, package);
 			if(info == NULL) {
 				ERR(NL, _("package \"%s\" not found\n"), package);
-				/* do not return on query operations - let's just carry on */
-				/*return(2);*/
 				continue;
 			}
 
 			/* find a target */
-			if(config->op_q_changelog || config->op_q_info || config->op_q_list) {
-				if(config->op_q_changelog) {
-					char changelog[PATH_MAX];
-					snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
-						alpm_option_get_root(), alpm_option_get_dbpath(),
-						alpm_db_get_name(db_local),
-						alpm_pkg_get_name(info),
-						alpm_pkg_get_version(info));
-					dump_pkg_changelog(changelog, alpm_pkg_get_name(info));
-				}
-				if(config->op_q_info) {
-					dump_pkg_full(info, config->op_q_info);
-				}
-				if(config->op_q_list) {
-					dump_pkg_files(info);
-				}
+			if(config->op_q_changelog) {
+				char changelog[PATH_MAX];
+				snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
+								 alpm_option_get_root(), alpm_option_get_dbpath(),
+								 alpm_db_get_name(db_local),
+								 alpm_pkg_get_name(info),
+								 alpm_pkg_get_version(info));
+				dump_pkg_changelog(changelog, alpm_pkg_get_name(info));
+			} else if(config->op_q_info) {
+				dump_pkg_full(info, config->op_q_info);
+			} else if(config->op_q_list) {
+				dump_pkg_files(info);
 			} else if(config->op_q_orphans) {
-					if(alpm_pkg_get_requiredby(info) == NULL) {
-						MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
-					}
+				if(alpm_pkg_get_requiredby(info) == NULL) {
+					MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
+				}
 			} else {
 				MSG(NL, "%s %s\n", alpm_pkg_get_name(info), alpm_pkg_get_version(info));
 			}




More information about the pacman-dev mailing list