[pacman-dev] patch-in-progress: cleanup, refactoring, etc.

Dan McGee dpmcgee at gmail.com
Wed Jan 24 11:53:23 EST 2007


I've made a few changes in my side branch that I've been maintaining
and wanted to see if anything here is good enough to be put on the
main line. I have the patch below and a comment or two before each
individual file diff explaining what I changed and why. Search for ***
to find my added comments.

-Dan

****These files should be removed here and not by make, since they are
created by configure, not make.
============================================================
--- autoclean.sh	1924ab94d4748bd719b6d05c3c9754e0ef6e5dc5
+++ autoclean.sh	f01e101d3eda8c4a5719702b7c73ac288dd7be57
@@ -36,6 +36,7 @@ rm -rf etc/pacman.d/Makefile
 rm -rf etc/Makefile
 rm -rf etc/pacman.d/Makefile.in
 rm -rf etc/pacman.d/Makefile
+rm -rf etc/pacman.d/{current,extra,community,unstable,release}
 rm -rf etc/abs/Makefile.in
 rm -rf etc/abs/Makefile


***Got rid of spurious spaces, cleaned up library checking code-- if
we don't have math, archive, or download, we can't build, and we don't
need to include them here, only in the specific directories they are
used.
============================================================
--- configure.ac	8358b1c0036a631a10901e015f2a3625c370863b
+++ configure.ac	4945cc3d67c50784681ee7de5301976c8fcafcd4
@@ -147,7 +147,7 @@ AC_ARG_ENABLE(debug,

 dnl Help line for debug
 AC_ARG_ENABLE(debug,
-    AC_HELP_STRING([  --enable-debug], [Enable debugging support]),
+    AC_HELP_STRING([--enable-debug], [Enable debugging support]),
     [debug=$enableval], [debug=yes])

 dnl Help line for fakeroot
@@ -292,26 +292,20 @@ dnl Check for math
 fi

 dnl Check for math
-AC_CHECK_LIB([m], [log10], [AC_CHECK_HEADER([math.h], [LIBM='-lm'])])
-if test -n "$LIBM"; then
-    LDFLAGS="$LDFLAGS $LIBM"
-else
-    AC_MSG_ERROR("math library not found!");
+AC_CHECK_LIB([m], [sqrt], [AC_CHECK_HEADER([math.h], [LIBM='-lm'])])
+if test -z "$LIBM"; then
+    AC_MSG_ERROR("math library needed to compile pacman!");
 fi

 dnl Check for libarchive
 AC_CHECK_LIB([archive], [archive_read_data],
[AC_CHECK_HEADER([archive.h], [LIBARCHIVE='-larchive'])])
-if test -n "$LIBARCHIVE"; then
-    LDFLAGS="$LDFLAGS $LIBARCHIVE"
-else
+if test -z "$LIBARCHIVE"; then
     AC_MSG_ERROR("libarchive is needed to compile pacman!");
 fi

 dnl Check for libdownload
 AC_CHECK_LIB([download], [downloadParseURL],
[AC_CHECK_HEADER([download.h], [LIBDOWNLOAD='-ldownload'])])
-if test -n "$LIBDOWNLOAD"; then
-    LDFLAGS="$LDFLAGS $LIBDOWNLOAD"
-else
+if test -z "$LIBDOWNLOAD"; then
     AC_MSG_ERROR("libdownload is needed to compile pacman!");
 fi

@@ -326,20 +320,20 @@ AC_MSG_CHECKING(for debug mode request)

 dnl Enable or disable debug code
 AC_MSG_CHECKING(for debug mode request)
-if test x$debug = xyes ; then
-    AM_CONDITIONAL(PACMAN_DEBUG, test x$debug = xyes)
+if test "$debug" = yes ; then
+    AM_CONDITIONAL(PACMAN_DEBUG, test "$debug" = "yes")
 	CFLAGS="$CFLAGS -g -Wall -Werror -std=c99 -DPACMAN_DEBUG"
 	LDFLAGS="$LDFLAGS -lmcheck"
     AC_MSG_RESULT(yes)
 else
-    AM_CONDITIONAL(PACMAN_DEBUG, test x$debug = xno)
+    AM_CONDITIONAL(PACMAN_DEBUG, test "$debug" = "no")
 	CFLAGS="$CFLAGS -Wall -std=c99"
     AC_MSG_RESULT(no)
 fi

 dnl Enable or disable fakeroot code
 AC_MSG_CHECKING(for fakeroot proof support)
-if test x$fakeroot = xyes ; then
+if test "$fakeroot" = "yes" ; then
 	AC_MSG_RESULT(yes)
 else
 	CFLAGS="$CFLAGS -DFAKEROOT"

***As stated above, these shouldn't be removed by the makefile.
============================================================
--- etc/pacman.d/Makefile.am	840cb3c81402c99b85ac891ca9aa6ea73c9a6665
+++ etc/pacman.d/Makefile.am	6ed630aed49de51817151acf1039130ca0f4186b
@@ -1,7 +1,6 @@ clean:
 EXTRA_DIST = community current extra release unstable

 clean:
-	rm $(EXTRA_DIST)

 install-data-hook:
 	mkdir -p $(DESTDIR)$(sysconfdir)/pacman.d ; \

***Include math library here where needed.
============================================================
--- lib/libalpm/Makefile.am	3c32b7ed489cabd115bb7d62d895513102f9723e
+++ lib/libalpm/Makefile.am	7e25d2b6af9cc5f0fbfb808e84c4cf06c31abfdd
@@ -40,7 +40,7 @@ libalpm_la_LDFLAGS = -no-undefined -vers
 libalpm_la_SOURCES = $(TARGETS)

 libalpm_la_LDFLAGS = -no-undefined -version-info $(PM_VERSION_INFO)
-libalpm_la_LIBADD = -larchive -ldownload
+libalpm_la_LIBADD = -larchive -ldownload -lm

 if HAS_DOXYGEN
 all: doxygen.in

***Two minor typing changes, probably not real necessary.
============================================================
--- lib/libalpm/alpm.c	4a523ffcb264a38c24b6c192702e7c6e437518f0
+++ lib/libalpm/alpm.c	c21f46f9408260ed9ffb15cfa98a167ef0d4aec5
@@ -566,7 +566,7 @@ char *alpm_pkg_name_hasarch(char *pkgnam
 	 * and
 	 *    package-name-bar-1.2.3-1
 	 */
-	int i = 0;
+	size_t i = 0;
 	char *arch, *cmp, *p;

 	if((p = strrchr(pkgname, '-'))) {
@@ -1008,7 +1008,7 @@ int alpm_parse_config(char *file, alpm_c
 						_alpm_log(PM_LOG_DEBUG, _("config: xfercommand: %s"), ptr);
 					} else if (!strcmp(key, "UPGRADEDELAY")) {
 						/* The config value is in days, we use seconds */
-						long ud = atol(ptr) * 60 * 60 *24;
+						time_t ud = atol(ptr) * 60 * 60 *24;
 						alpm_option_set_upgradedelay(ud);
 						_alpm_log(PM_LOG_DEBUG, _("config: upgradedelay: %d"), ud);
 					} else {

***Refactor square root so it is only called once.
============================================================
--- lib/libalpm/deps.c	600ed931f1f4e65ee5d87065d81cd0d17d34857d
+++ lib/libalpm/deps.c	dc04f286046eefcb489b10bab01ded162c357e82
@@ -106,6 +106,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_
 	int change = 1;
 	int numscans = 0;
 	int numtargs = 0;
+	int maxscans;

 	if(targets == NULL) {
 		return(NULL);
@@ -116,15 +117,14 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_
 		numtargs++;
 	}

+	/* calculate this here so we aren't doing it each loop */
+	maxscans = (int)sqrt(numtargs);
+
 	_alpm_log(PM_LOG_DEBUG, _("started sorting dependencies"));
 	while(change) {
 		alpm_list_t *tmptargs = NULL;
 		change = 0;
-		/* TODO only use of a math.h function in entire libalpm,
-		 *      can we get rid of it? Former code line:
-		 *if(numscans > numtargs) {
-		 */
-		if(numscans > sqrt(numtargs)) {
+		if(numscans > maxscans) {
 			_alpm_log(PM_LOG_DEBUG, _("possible dependency cycle detected"));
 			continue;
 		}
@@ -321,9 +321,9 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *
 				/* else if still not found... */
 				if(!found) {
 					_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as a dependency for %s"),
-							depend.name, tp->name);
+					          depend.name, tp->name);
 					miss = _alpm_depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod,
-							depend.name, depend.version);
+					                         depend.name, depend.version);
 					if(!_alpm_depmiss_isin(miss, baddeps)) {
 						baddeps = alpm_list_add(baddeps, miss);
 					} else {

***Just quick updates to script- update version number, convert `` to $().
============================================================
--- scripts/makeworld	3295e2dacc2a9c6e391f6fc76ee591c95a887744
+++ scripts/makeworld	b341ff0d4176b487df69da2bc015890263a42910
@@ -20,8 +20,8 @@
 #   USA.
 #

-version="2.9.8"
-toplevel=`pwd`
+version="3.0.0"
+toplevel=$(pwd)

 usage() {
 	echo "makeworld version $version"
@@ -119,13 +119,13 @@ cd $dest

 # convert a (possibly) relative path to absolute
 cd $dest
-dest=`pwd`
+dest=$(pwd)
 cd - &>/dev/null

-sd=`date +"[%b %d %H:%M]"`
+sd=$(date +"[%b %d %H:%M]")

 for category in $*; do
-	for port in `find $toplevel/$category -maxdepth 1 -mindepth 1 -type
d | sort`; do
+	for port in $(find $toplevel/$category -maxdepth 1 -mindepth 1 -type
d | sort); do
 		cd $port
 		if [ -f PKGBUILD ]; then
 			. PKGBUILD
@@ -138,7 +138,7 @@ for category in $*; do
 					buildstatus=1
 				fi
 			fi
-			d=`date +"[%b %d %H:%M]"`
+			d=$(date +"[%b %d %H:%M]")
 			echo -n "$d  " >>$toplevel/build.log
 			case $buildstatus in
 				0) echo "$pkgname already built -- skipping" >>$toplevel/build.log ;;
@@ -148,7 +148,7 @@ done
 		fi
 	done
 done
-ed=`date +"[%b %d %H:%M]"`
+ed=$(date +"[%b %d %H:%M]")

 echo "makeworld complete." >>$toplevel/build.log
 echo "  started:  $sd" >>$toplevel/build.log

***With some changes below, no longer need math library on frontend.
Be sure to sanity check my changes below, however.
============================================================
--- src/pacman/Makefile.am	4f082673b275a96c909b442bf3bcff121bc00d33
+++ src/pacman/Makefile.am	54351cf1782dd3d0e8fedf766250f7a77145b1c3
@@ -17,9 +17,9 @@ pacman_LDADD = -L$(top_srcdir)/lib/libal
 pacman_static_SOURCES = $(pacman_SOURCES)

 pacman_LDADD = -L$(top_srcdir)/lib/libalpm/.libs \
-			   -ldownload -lm -lalpm
+			   -ldownload -lalpm

 pacman_static_LDADD = -L$(top_srcdir)/lib/libalpm/.libs/ \
-					  -ldownload -lm -lalpm
+					  -ldownload -lalpm

 pacman_static_LDFLAGS = $(LDFLAGS) -all-static

***Changed type to match return type and moved it up to variable declaration.
============================================================
--- src/pacman/downloadprog.c	7d676cc84c01eff241f7b3abbf8eca9e7d45b1dc
+++ src/pacman/downloadprog.c	3fbd45421973235cdb2e5b000ca17735f9a4f0d6
@@ -53,7 +53,9 @@ void log_progress(const char *filename,
 {
 	static unsigned int lasthash = 0, mouth = 0;
 	unsigned int i, hash;
-	unsigned int chomp = 0;
+	/* a little hard to conceal easter eggs in open-source software,
+	 * but they're still fun. ;) */
+	const unsigned short chomp = alpm_option_get_chomp();
 	char *fname, *p;
 	unsigned int maxcols = getcols();
 	unsigned int progresslen = maxcols - 57;
@@ -75,9 +77,6 @@ void log_progress(const char *filename,
 		return;
 	}

-	/* a little hard to conceal easter eggs in open-source software, but
they're still fun. ;) */
-	chomp = alpm_option_get_chomp();
-
 	gettimeofday(&current_time, NULL);
 	total_timediff = current_time.tv_sec-initial_time.tv_sec
 		+ (float)(current_time.tv_usec-initial_time.tv_usec) / 1000000;

***Reorder options so pacman -Qi and pacman -Si output are much more
similar (to the extent they can be). Also, print sizes using kilobytes
instead of bytes.
============================================================
--- src/pacman/package.c	83c565ab5f2ce16c6029730312e3fc36e0fc5a34
+++ src/pacman/package.c	6843843535db726227361a3955a1ee4f0e7c413b
@@ -63,24 +63,25 @@ void dump_pkg_full(pmpkg_t *pkg, int lev
 	/* actual output */
 	printf(_("Name           : %s\n"), (char *)alpm_pkg_get_name(pkg));
 	printf(_("Version        : %s\n"), (char *)alpm_pkg_get_version(pkg));
+	printf(_("URL            : %s\n"), (char *)alpm_pkg_get_url(pkg));
+	list_display(_("License        :"), alpm_pkg_get_licenses(pkg));
 	list_display(_("Groups         :"), alpm_pkg_get_groups(pkg));
+	list_display(_("Provides       :"), alpm_pkg_get_provides(pkg));
+	list_display(_("Depends On     :"), alpm_pkg_get_depends(pkg));
+	list_display(_("Removes        :"), alpm_pkg_get_removes(pkg));
+	/* TODO only applicable if querying installed package, not a file */
+	list_display(_("Required By    :"), alpm_pkg_get_requiredby(pkg));
+	list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
+	printf(_("Installed Size : %ld K\n"), (long)alpm_pkg_get_size(pkg) / 1024);
 	printf(_("Packager       : %s\n"), (char *)alpm_pkg_get_packager(pkg));
-	printf(_("URL            : %s\n"), (char *)alpm_pkg_get_url(pkg));
-	list_display(_("License        :"), alpm_pkg_get_licenses(pkg));
 	printf(_("Architecture   : %s\n"), (char *)alpm_pkg_get_arch(pkg));
-	printf(_("Installed Size : %ld\n"), (long int)alpm_pkg_get_size(pkg));
 	printf(_("Build Date     : %s %s\n"), bdate, strlen(bdate) ? "UTC" : "");
 	printf(_("Build Type     : %s\n"), strlen(type) ? type : _("Unknown"));
 	/* TODO only applicable if querying installed package, not a file */
 	printf(_("Install Date   : %s %s\n"), idate, strlen(idate) ? "UTC" : "");
 	printf(_("Install Script : %s\n"), alpm_pkg_has_scriptlet(pkg) ?
_("Yes") : _("No"));
 	printf(_("Reason         : %s\n"), reason);
-	list_display(_("Provides       :"), alpm_pkg_get_provides(pkg));
-	list_display(_("Depends On     :"), alpm_pkg_get_depends(pkg));
-	list_display(_("Removes        :"), alpm_pkg_get_removes(pkg));
 	/* TODO only applicable if querying installed package, not a file */
-	list_display(_("Required By    :"), alpm_pkg_get_requiredby(pkg));
-	list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));

 	printf(_("Description    : "));
 	indentprint(alpm_pkg_get_desc(pkg), 17);
@@ -117,8 +118,8 @@ void dump_pkg_sync(pmpkg_t *pkg, const c
 	list_display(_("Removes        :"), alpm_pkg_get_removes(pkg));
 	list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
 	list_display(_("Replaces       :"), alpm_pkg_get_replaces(pkg));
-	printf(_("Download Size  : %ld\n"), (long)alpm_pkg_get_size(pkg));
-	printf(_("Installed Size : %ld\n"), (long)alpm_pkg_get_isize(pkg));
+	printf(_("Download Size  : %ld K\n"), (long)alpm_pkg_get_size(pkg) / 1024);
+	printf(_("Installed Size : %ld K\n"), (long)alpm_pkg_get_isize(pkg) / 1024);
 	
 	printf(_("Description    : "));
 	indentprint(alpm_pkg_get_desc(pkg), 17);

***Reword a usage instruction.
============================================================
--- src/pacman/pacman.c	1b006c77745dc36301ee96f5dfc4ce231124342f
+++ src/pacman/pacman.c	7894fabbf4e27e17090dbecb8235ffcfbf60210e
@@ -123,8 +123,8 @@ static void usage(int op, char *myname)
 			printf(_("usage:  %s {-Q --query} [options] [package]\n"), myname);
 			printf(_("options:\n"));
 			printf(_("  -c, --changelog     view the changelog of a package\n"));
-			printf(_("  -e, --orphans       list all packages that were
installed as a dependency\n"));
-			printf(_("                      and are not required by any other
packages\n"));
+			printf(_("  -e, --orphans       list all packages installed as
dependencies but no longer\n"
+			         "                      required by any package\n"));
 			printf(_("  -g, --groups        view all members of a package group\n"));
 			printf(_("  -i, --info          view package information\n"));
 			printf(_("  -l, --list          list the contents of the queried
package\n"));

***Remove use of math.h by making assumptions about the possible range
of the former log10 call. As long as we are installing <1000 packages
(a reasonable assumption?), this new code works fine.
***Refactor two functions out to allow better variable declaration
(closer to where they are actually used, and not initialized if
unused). fill_progress might also be applicable now in the other
status bar display (downloadprog, I believe).
***Fix indenting of a switch statement.
============================================================
--- src/pacman/trans.c	1f02954b56601d065e49e0c52c92e3af395c65fd
+++ src/pacman/trans.c	7ea136c95d81f51115ff6bab946917be89a71b13
@@ -26,7 +26,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <dirent.h>
-#include <math.h>
 #include <libintl.h>

 #include <alpm.h>
@@ -42,13 +41,84 @@ static int prevpercent=0; /* for less pr

 static int prevpercent=0; /* for less progressbar output */

+/* static function declarations */
+static void retrieve_local(void *data1, void *data2);
+static void fill_progress(int percent);
+
+/* refactored function from below because of variable declaration */
+static void retrieve_local(void *data1, void *data2)
+{
+	const unsigned int maxcols = getcols();
+	char out[PATH_MAX];
+	unsigned int i;
+
+	MSG(NL, " %s [", (char*)data1);
+	STRNCPY(out, (char*)data2, maxcols-42);
+	MSG(CL, "%s", out);
+	for(i = strlen(out); i < maxcols-43; i++) {
+		MSG(CL, " ");
+	}
+	fputs(_("] 100%    LOCAL "), stdout);
+}
+
+/* refactored from below to make variable declaration cleaner */
+static void fill_progress(int percent)
+{
+	const unsigned short chomp = alpm_option_get_chomp();
+	const unsigned int progresslen = getcols() - 57;
+	const unsigned int hash = percent * progresslen / 100;
+	unsigned int lasthash = 0, mouth = 0;
+	unsigned int i;
+
+	/* hide the cursor, prevent flicker during fancy graphics
+	printf("\033[?25l\033[?1c[");
+	*/
+	printf("[");
+	for(i = progresslen; i > 1; --i) {
+		/* if special progress bar enabled */
+		if(chomp) {
+			if(i > progresslen - hash) {
+				printf("-");
+			} else if(i == progresslen - hash) {
+				if(lasthash == hash) {
+					if(mouth) {
+						printf("\033[1;33mC\033[m");
+					} else {
+						printf("\033[1;33mc\033[m");
+					}
+				} else {
+					lasthash = hash;
+					mouth = mouth == 1 ? 0 : 1;
+					if(mouth) {
+						printf("\033[1;33mC\033[m");
+					} else {
+						printf("\033[1;33mc\033[m");
+					}
+				}
+			} else if(i%3 == 0) {
+				printf("\033[0;37mo\033[m");
+			} else {
+				printf("\033[0;37m \033[m");
+			}
+		} /* else regular progress bar */
+		else if(i > progresslen - hash) {
+			printf("#");
+		} else {
+			printf("-");
+		}
+	}
+	printf("] %3d%%\r", percent);
+
+	if(percent == 100) {
+		printf("\n");
+	}
+}
+
 /* Callback to handle transaction events
  */
 void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
 {
 	char str[LOG_STR_LEN] = "";
-	char out[PATH_MAX];
-	int i;

 	switch(event) {
 		case PM_TRANS_EVT_CHECKDEPS_START:
@@ -155,14 +225,7 @@ void cb_trans_evt(pmtransevt_t event, vo
 			fflush(stdout);
 			break;
 		case PM_TRANS_EVT_RETRIEVE_LOCAL:
-			MSG(NL, " %s [", (char*)data1);
-			unsigned int maxcols = getcols();
-			STRNCPY(out, (char*)data2, maxcols-42);
-			MSG(CL, "%s", out);
-			for(i = strlen(out); i < maxcols-43; i++) {
-				MSG(CL, " ");
-			}
-			fputs(_("] 100%    LOCAL "), stdout);
+			retrieve_local(data1, data2);
 			break;
 	}
 }
@@ -289,11 +352,14 @@ void cb_trans_progress(pmtransprog_t eve
 void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
                        int howmany, int remain)
 {
-	static int lasthash = 0, mouth = 0;
-	int i, hash;
-	long chomp = 0;
-	unsigned int maxcols = getcols();
-	unsigned int maxpkglen, progresslen = maxcols - 57;
+	/* these 3 vars determine size of the howmany/remaining packages counter
+	 *   change from log10 allows elimination of math library from front end
+	 *   former code: log10(howmany) or log10(remain)
+	 *   current code: identical to above as long as value < 1000 */
+	const int digitshm= howmany < 10 ? 1 : (howmany < 100 ? 2 : 3);
+	const int digitsr = remain < 10 ? 1 : (remain < 100 ? 2 : 3);
+	unsigned int maxpkglen;
+	int i;
 	char *ptr = NULL;

 	if(config->noprogressbar) {
@@ -306,12 +372,8 @@ void cb_trans_progress(pmtransprog_t eve
 		set_output_padding(0); /* shut it off again */
 	}

-	if (!pkgname)
+	if (!pkgname || percent > 100 || percent == prevpercent)
 		return;
-	if (percent > 100)
-		return;
-	if(percent == prevpercent)
-		return;

 	prevpercent=percent;
 	switch (event) {
@@ -331,78 +393,38 @@ void cb_trans_progress(pmtransprog_t eve
 			ptr = _("checking for file conflicts");
 			break;
 	}
-	hash=percent*progresslen/100;

-	// if the package name is too long, then slice the ending
-	maxpkglen=46-strlen(ptr)-(3+2*(int)log10(howmany));
-	if(strlen(pkgname)>maxpkglen)
-		pkgname[maxpkglen]='\0';
+	maxpkglen = 46 - strlen(ptr) - (3 + 2 * digitshm);

+	/* if the package name is too long, then slice the ending */
+	if(strlen(pkgname) > maxpkglen)
+		pkgname[maxpkglen] = '\0';
+
 	switch (event) {
-	case PM_TRANS_PROGRESS_ADD_START:
-	case PM_TRANS_PROGRESS_UPGRADE_START:
-	case PM_TRANS_PROGRESS_REMOVE_START:
-		putchar('(');
-		for(i=0;i<(int)log10(howmany)-(int)log10(remain);i++)
-			putchar(' ');
-		printf("%d/%d) %s %s ", remain, howmany, ptr, pkgname);
-		if (strlen(pkgname)<maxpkglen)
-			for (i=maxpkglen-strlen(pkgname)-1; i>0; i--)
+		case PM_TRANS_PROGRESS_ADD_START:
+		case PM_TRANS_PROGRESS_UPGRADE_START:
+		case PM_TRANS_PROGRESS_REMOVE_START:
+			putchar('(');
+			for(i = 0;i < digitshm - digitsr; i++)
 				putchar(' ');
-		break;
+			printf("%d/%d) %s %s ", remain, howmany, ptr, pkgname);
+			if (strlen(pkgname) < maxpkglen)
+				for (i = maxpkglen - strlen(pkgname) - 1; i > 0; i--)
+					putchar(' ');
+			break;

-	case PM_TRANS_PROGRESS_CONFLICTS_START:
-		printf("%s (", ptr);
-		for(i=0;i<(int)log10(howmany)-(int)log10(remain);i++)
-			putchar(' ');
-		printf("%d/%d) ", remain, howmany);
-		for (i=maxpkglen; i>0; i--)
-			putchar(' ');
-		break;
-	}
+		case PM_TRANS_PROGRESS_CONFLICTS_START:
+			printf("%s (", ptr);
+			for(i = 0; i < digitshm - digitsr; i++)
+				putchar(' ');
+			printf("%d/%d) ", remain, howmany);
+			for (i = maxpkglen; i > 0; i--)
+				putchar(' ');
+			break;

-	chomp = alpm_option_get_chomp();
-
-	/* hide the cursor, prevent flicker during fancy graphics
-	printf("\033[?25l\033[?1c[");
-	*/
-	printf("[");
-	for(i = progresslen; i > 0; --i) {
-		if(chomp) {
-			if(i > progresslen - hash) {
-				printf("-");
-			} else if(i == progresslen - hash) {
-				if(lasthash == hash) {
-					if(mouth) {
-						printf("\033[1;33mC\033[m");
-					} else {
-						printf("\033[1;33mc\033[m");
-					}
-				} else {
-					lasthash = hash;
-					mouth = mouth == 1 ? 0 : 1;
-					if(mouth) {
-						printf("\033[1;33mC\033[m");
-					} else {
-						printf("\033[1;33mc\033[m");
-					}
-				}
-			} else if(i%3 == 0) {
-				printf("\033[0;37mo\033[m");
-			} else {
-				printf("\033[0;37m \033[m");
-			}
-		} else if(i > progresslen - hash) {
-			printf("#");
-		} else {
-			printf("-");
-		}
 	}
-	printf("] %3d%%\r", percent);

-	if(percent == 100) {
-		printf("\n");
-	}
+	fill_progress(percent);
 }

 /* vim: set ts=2 sw=2 noet: */

***Add a missing comment.
============================================================
--- src/pacman/trans.h	4d7d7f9b948979d070bcc648027c26b73c7732d3
+++ src/pacman/trans.h	1fd2c160d34e607571f0829820c924f6179f8193
@@ -28,6 +28,7 @@ void cb_trans_conv(pmtransconv_t event,
 void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
                    void *data3, int *response);

+/* callback to handle display of the progress bar for transactions */
 void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
                    int howmany, int remain);

***Slight type change to match where it is used.
============================================================
--- src/pacman/util.c	c553258df09eae12fbdd31a68295c1e47097a030
+++ src/pacman/util.c	f30c0a9ab665739c13b47bb33b44e086c88c3783
@@ -168,7 +168,7 @@ void indentprint(const char *str, unsign
 	while(*p) {
 		if(*p == ' ') {
 			const char *next = NULL;
-			int len;
+			unsigned int len;
 			p++;
 			if(p == NULL || *p == ' ') continue;
 			next = strchr(p, ' ');




More information about the pacman-dev mailing list