[pacman-dev] CVS update of pacman-lib (4 files)

dan at archlinux.org dan at archlinux.org
Wed Feb 14 10:54:36 EST 2007


    Date: Wednesday, February 14, 2007 @ 10:54:36
  Author: dan
    Path: /home/cvs-pacman/pacman-lib

Modified: lib/libalpm/util.c (1.45 -> 1.46) lib/libalpm/util.h (1.21 -> 1.22)
          src/pacman/package.c (1.29 -> 1.30)
          src/pacman/trans.c (1.33 -> 1.34)

* strlen -> mbstowcs (multibyte str to wide char str) conversion where we
  want the actual number of characters, not the number of bytes.
* Added a TODO to take care of later in scriptlet processing.


----------------------+
 lib/libalpm/util.c   |   18 +++++++++++++-----
 lib/libalpm/util.h   |    1 +
 src/pacman/package.c |    4 ++--
 src/pacman/trans.c   |    2 +-
 4 files changed, 17 insertions(+), 8 deletions(-)


Index: pacman-lib/lib/libalpm/util.c
diff -u pacman-lib/lib/libalpm/util.c:1.45 pacman-lib/lib/libalpm/util.c:1.46
--- pacman-lib/lib/libalpm/util.c:1.45	Tue Feb 13 03:15:38 2007
+++ pacman-lib/lib/libalpm/util.c	Wed Feb 14 10:54:35 2007
@@ -509,12 +509,19 @@
 			char line[1024];
 			if(fgets(line, 1024, pp) == NULL)
 				break;
+			/*TODO clean this code up, remove weird SCRIPTLET_START/DONE,
+			 * (void*)atol call, etc. */
 			/* "START <event desc>" */
-			if((strlen(line) > strlen(SCRIPTLET_START)) && !strncmp(line, SCRIPTLET_START, strlen(SCRIPTLET_START))) {
-				EVENT(trans, PM_TRANS_EVT_SCRIPTLET_START, _alpm_strtrim(line + strlen(SCRIPTLET_START)), NULL);
+			if((strlen(line) > strlen(SCRIPTLET_START))
+			   && !strncmp(line, SCRIPTLET_START, strlen(SCRIPTLET_START))) {
+				EVENT(trans, PM_TRANS_EVT_SCRIPTLET_START,
+				      _alpm_strtrim(line + strlen(SCRIPTLET_START)), NULL);
 			/* "DONE <ret code>" */
-			} else if((strlen(line) > strlen(SCRIPTLET_DONE)) && !strncmp(line, SCRIPTLET_DONE, strlen(SCRIPTLET_DONE))) {
-				EVENT(trans, PM_TRANS_EVT_SCRIPTLET_DONE, (void*)atol(_alpm_strtrim(line + strlen(SCRIPTLET_DONE))), NULL);
+			} else if((strlen(line) > strlen(SCRIPTLET_DONE))
+			          && !strncmp(line, SCRIPTLET_DONE, strlen(SCRIPTLET_DONE))) {
+				EVENT(trans, PM_TRANS_EVT_SCRIPTLET_DONE,
+				      (void*)atol(_alpm_strtrim(line + strlen(SCRIPTLET_DONE))),
+				      NULL);
 			} else {
 				_alpm_strtrim(line);
 				/* log our script output */
@@ -526,7 +533,8 @@
 		exit(0);
 	} else {
 		if(waitpid(pid, 0, 0) == -1) {
-			_alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)"), strerror(errno));
+			_alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)"),
+			          strerror(errno));
 			retval = 1;
 			goto cleanup;
 		}
Index: pacman-lib/lib/libalpm/util.h
diff -u pacman-lib/lib/libalpm/util.h:1.21 pacman-lib/lib/libalpm/util.h:1.22
--- pacman-lib/lib/libalpm/util.h:1.21	Tue Feb 13 03:15:38 2007
+++ pacman-lib/lib/libalpm/util.h	Wed Feb 14 10:54:35 2007
@@ -51,6 +51,7 @@
 #define _(s) s
 #endif
 
+/*TODO wtf? why is this done like this? */
 #define SCRIPTLET_START "START "
 #define SCRIPTLET_DONE "DONE "
 
Index: pacman-lib/src/pacman/package.c
diff -u pacman-lib/src/pacman/package.c:1.29 pacman-lib/src/pacman/package.c:1.30
--- pacman-lib/src/pacman/package.c:1.29	Mon Feb 12 10:39:29 2007
+++ pacman-lib/src/pacman/package.c	Wed Feb 14 10:54:35 2007
@@ -94,7 +94,7 @@
 
 	/* printed using a variable to make i18n safe */
 	printf("%s", descheader);
-	indentprint(alpm_pkg_get_desc(pkg), strlen(descheader));
+	indentprint(alpm_pkg_get_desc(pkg), mbstowcs(NULL, descheader, 0));
 	printf("\n");
 
 	/* Print additional package info if info flag passed more than once */
@@ -134,7 +134,7 @@
 	
 	/* printed using a variable to make i18n safe */
 	printf("%s", descheader);
-	indentprint(alpm_pkg_get_desc(pkg), strlen(descheader));
+	indentprint(alpm_pkg_get_desc(pkg), mbstowcs(NULL, descheader, 0));
 	printf("\n");
 	
 	if (md5sum != NULL && md5sum[0] != '\0') {
Index: pacman-lib/src/pacman/trans.c
diff -u pacman-lib/src/pacman/trans.c:1.33 pacman-lib/src/pacman/trans.c:1.34
--- pacman-lib/src/pacman/trans.c:1.33	Fri Feb  9 11:02:01 2007
+++ pacman-lib/src/pacman/trans.c	Wed Feb 14 10:54:35 2007
@@ -334,7 +334,7 @@
 	/* determine room left for non-digits text [not ( 1/12) part] */
 	textlen = infolen - 3 - (2 * digits);
 	/* room left for package name */
-	pkglen = textlen - strlen(ptr) - 1;
+	pkglen = textlen - mbstowcs(NULL, ptr, 0) - 1;
 
 	switch (event) {
 		case PM_TRANS_PROGRESS_ADD_START:




More information about the pacman-dev mailing list