From: Rocco Rutte Date: Mon, 17 Sep 2007 13:42:34 +0000 (+0200) Subject: Enable padding with multibyte chars for %>X, %*X and %|X X-Git-Tag: mutt-1-5-17-rel~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b6179eed7990c99a440655990b1d1a796e662fa;p=mutt Enable padding with multibyte chars for %>X, %*X and %|X --- diff --git a/ChangeLog b/ChangeLog index 020b12b7..6f8cb5f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-09-17 13:05 +0200 Rocco Rutte (6f06b7f1f76f) + + * main.c: Mark interesting items in mutt -v output for translation + +2007-09-17 11:35 +0200 Rocco Rutte (010084b62288) + + * ChangeLog, hcache.c, hcache.h, main.c: Include hcache backend + version info in mutt -v output + 2007-09-17 09:47 +0200 Rocco Rutte (e146db07dd54) * init.c: Use NONULL to ensure we can pretty-print empty paths for diff --git a/muttlib.c b/muttlib.c index 5f25462f..ca06d27c 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1200,28 +1200,34 @@ void mutt_FormatString (char *dest, /* output buffer */ /* %>X: right justify to EOL, left takes precedence * %*X: right justify to EOL, right takes precedence */ int soft = ch == '*'; - ch = *src++; /* pad char (if there's room) */ + int pl, pw; + if ((pl = mutt_charlen (src, &pw)) <= 0) + pl = pw = 1; + /* see if there's room to add content, else ignore */ if ((col < COLS && wlen < destlen) || soft) { int pad; /* get contents after padding */ - mutt_FormatString (buf, sizeof (buf), 0, src, callback, data, flags); + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); len = mutt_strlen (buf); wid = mutt_strwidth (buf); /* try to consume as many columns as we can, if we don't have * memory for that, use as much memory as possible */ - pad = COLS - col - wid; - if (wlen + pad + len > destlen) - pad = destlen - wlen - len; + pad = (COLS - col - wid) / pw; + if (pad > 0 && wlen + (pad * pl) + len > destlen) + pad = ((signed)(destlen - wlen - len)) / pl; if (pad > 0) { - memset (wptr, ch, pad); - wptr += pad; - wlen += pad; - col += pad; + while (pad--) + { + memcpy (wptr, src, pl); + wptr += pl; + wlen += pl; + col += pw; + } } else if (soft && pad < 0) { @@ -1240,20 +1246,32 @@ void mutt_FormatString (char *dest, /* output buffer */ wptr += len; wlen += len; col += wid; + src += pl; } break; /* skip rest of input */ } else if (ch == '|') { /* pad to EOL */ - ch = *src++; - if (destlen > COLS) - destlen = COLS; - if (destlen > wlen) + int pl, pw, c; + if ((pl = mutt_charlen (src, &pw)) <= 0) + pl = pw = 1; + + /* see if there's room to add content, else ignore */ + if (col < COLS && wlen < destlen) { - count = destlen - wlen; - memset (wptr, ch, count); - wptr += count; + c = (COLS - col) / pw; + if (c > 0 && wlen + (c * pl) > destlen) + c = ((signed)(destlen - wlen)) / pl; + while (c > 0) + { + memcpy (wptr, src, pl); + wptr += pl; + wlen += pl; + col += pw; + c--; + } + src += pl; } break; /* skip rest of input */ }