]> granicus.if.org Git - mutt/commitdiff
Make to_chars and status_chars accept mulitibyte characters. (closes #3024)
authorKevin McCarthy <kevin@8t8.us>
Tue, 27 Dec 2016 23:23:37 +0000 (15:23 -0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 27 Dec 2016 23:23:37 +0000 (15:23 -0800)
Change Tochars and StChars to use the mbchars_table type introduced in
the last commit.

globals.h
hdrline.c
init.h
status.c

index 30ad44139eaf20d4db4d8ad76f8f37734589ce67..ebcc47897cf2c3bf7343564db7dad70d950430cb 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -144,10 +144,10 @@ WHERE short SslDHPrimeBits;
 WHERE char *SslCACertFile INITVAL (NULL);
 #endif
 #endif
-WHERE char *StChars;
+WHERE mbchar_table *StChars;
 WHERE char *Status;
 WHERE char *Tempdir;
-WHERE char *Tochars;
+WHERE mbchar_table *Tochars;
 WHERE char *TrashPath;
 WHERE char *TSStatusFormat;
 WHERE char *TSIconFormat;
index 2d44de346d79b5dc14e0a877935178ecb56724ca..102484691fd34f6ab7c722c031022ec71ee7c69d 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -620,9 +620,9 @@ hdr_format_str (char *dest,
       break;
 
     case 'T':
-      snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
+      snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
       snprintf (dest, destlen, fmt,
-               (Tochars && ((i = mutt_user_is_recipient (hdr))) < mutt_strlen (Tochars)) ? Tochars[i] : ' ');
+               (Tochars && ((i = mutt_user_is_recipient (hdr))) < Tochars->len) ? Tochars->chars[i] : " ");
       break;
 
     case 'u':
@@ -668,13 +668,13 @@ hdr_format_str (char *dest,
         ch = 'K';
 
       snprintf (buf2, sizeof (buf2),
-               "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' : 
+               "%c%c%s", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' :
                ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
                ? (hdr->replied ? 'r' : ' ') : (hdr->old ? 'O' : 'N')))),
                hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch),
-               hdr->tagged ? '*' :
-               (hdr->flagged ? '!' :
-                (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' ')));
+               hdr->tagged ? "*" :
+               (hdr->flagged ? "!" :
+                (Tochars && ((i = mutt_user_is_recipient (hdr)) < Tochars->len) ? Tochars->chars[i] : " ")));
       mutt_format_s (dest, destlen, prefix, buf2);
       break;
 
diff --git a/init.h b/init.h
index aacc492ef5839bdc81a0f646b8fe516313b19598..6d23e2d5747e08018c055411ead073ae1caad9ff 100644 (file)
--- a/init.h
+++ b/init.h
@@ -3386,7 +3386,7 @@ struct option_t MuttVars[] = {
   ** required.)
   */
 #endif /* defined(USE_SSL) */
-  { "status_chars",    DT_STR,  R_BOTH, UL &StChars, UL "-*%A" },
+  { "status_chars",    DT_MBCHARTBL, R_BOTH, UL &StChars, UL "-*%A" },
   /*
   ** .pp
   ** Controls the characters used by the ``%r'' indicator in
@@ -3570,7 +3570,7 @@ struct option_t MuttVars[] = {
   ** this variable is not set, the environment variable \fC$$$TMPDIR\fP is
   ** used.  If \fC$$$TMPDIR\fP is not set then ``\fC/tmp\fP'' is used.
   */
-  { "to_chars",                DT_STR,  R_BOTH, UL &Tochars, UL " +TCFL" },
+  { "to_chars",                DT_MBCHARTBL, R_BOTH, UL &Tochars, UL " +TCFL" },
   /*
   ** .pp
   ** Controls the character used to indicate mail addressed to you.  The
index 52baa8c1d79afeccf48f361bc4959b95ea351d8e..b19fb4126d08c679f24af2d4b27227efc154d693 100644 (file)
--- a/status.c
+++ b/status.c
@@ -228,14 +228,12 @@ status_format_str (char *buf, size_t buflen, size_t col, int cols, char op, cons
            Context->deleted)) ? 1 : 0);
       }
       
-      if (!StChars)
+      if (!StChars || !StChars->len)
        buf[0] = 0;
-      else if (i >= mutt_strlen(StChars))
-       buf[0] = StChars[0];
+      else if (i >= StChars->len)
+        snprintf (buf, buflen, "%s", StChars->chars[0]);
       else
-       buf[0] = StChars[i];
-
-      buf[1] = 0;
+        snprintf (buf, buflen, "%s", StChars->chars[i]);
       break;
     }