]> granicus.if.org Git - mutt/commitdiff
Enable padding with multibyte chars for %>X, %*X and %|X
authorRocco Rutte <pdmef@gmx.net>
Mon, 17 Sep 2007 13:42:34 +0000 (15:42 +0200)
committerRocco Rutte <pdmef@gmx.net>
Mon, 17 Sep 2007 13:42:34 +0000 (15:42 +0200)
ChangeLog
muttlib.c

index 020b12b7d502e5a172e1949c21b3aedfafc51058..6f8cb5f5f879c4001f57ac9aea430375d83f3016 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-09-17 13:05 +0200  Rocco Rutte  <pdmef@gmx.net>  (6f06b7f1f76f)
+
+       * main.c: Mark interesting items in mutt -v output for translation
+
+2007-09-17 11:35 +0200  Rocco Rutte  <pdmef@gmx.net>  (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  <pdmef@gmx.net>  (e146db07dd54)
 
        * init.c: Use NONULL to ensure we can pretty-print empty paths for
index 5f25462fee5feada6cc6bb0c2f967182a3abc358..ca06d27cfa5427237313b32ed3586df11ba1eba2 100644 (file)
--- 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 */
       }