[pacman-dev] Several output issues

Xavier shiningxc at gmail.com
Fri Sep 14 14:28:52 EDT 2007


On Fri, Sep 14, 2007 at 11:15:19AM -0500, Aaron Griffin wrote:
> On 9/14/07, Xavier <shiningxc at gmail.com> wrote:
> > Just did some testing with pacman 3.0 :
> > using english output, it worked fine, but in french, there already was a little
> > problem :
> > (1/1) Analyse des conflits entre fichiers           [############################################] 100%
> > Avertissement: /etc/X11/twm/system.twmrc installé en tant que /etc/X11/twm/system.twmrc.pacnew        %
> > (1/1) Mise à jour xorg-twm                          [############################################] 100%
> >
> >
> > Just the % appeared at the end of the line.
> > That's still better than the current pacman 3.1 output, as seen in my first post.
> 
> Random guess without looking at it, this is another "fail at
> calculating the line length due to accented chars".

Yes, that was the problem indeed.
Since I didn't know anything about this stuff, I asked for some help on ##c :)
So it's possible to compute the real number of characters using mblen in a
loop. I did that on pacman 3.0 and it works fine, the above problem is fixed.

About pacman 3.1 , I see Dan removed that pm_printf function, and later added
back a much simpler version of it, without all that padding stuff.
So maybe the old version should be restored?


--- pacman-3.0.5/src/pacman/log.c	2007-03-13 17:15:38.000000000 +0100
+++ pacman-3.0.5-new/src/pacman/log.c	2007-09-14 20:15:32.000000000 +0200
@@ -135,7 +135,14 @@
 
 	if(needpad == 1) {
 		int i, cols = getcols();
-		for(i=len; i < cols; ++i) {
+		/* compute the number of multibyte characters */
+		int nchar = 0;
+		char *p = str;
+		while(*p) {
+			nchar += mblen(p, 2);
+			p++;
+		}
+		for(i=nchar; i < cols; ++i) {
 			fprintf(file, " ");
 		}
 		if(neednl == 1 && line == NL) {




More information about the pacman-dev mailing list