Make to_chars and status_chars accept mulitibyte characters. (closes #3024)
Change Tochars and StChars to use the mbchars_table type introduced in the last patch. -- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
# HG changeset patch # User Kevin McCarthy <ke...@8t8.us> # Date 1481685440 28800 # Tue Dec 13 19:17:20 2016 -0800 # Node ID f42b309b92b8d6561f3bfeeb52c2b759dd4811a0 # Parent eb09bb75f18345bf9550c25cf32041343df486fe Make to_chars and status_chars accept mulitibyte characters. (closes #3024) Change Tochars and StChars to use the mbchars_table type introduced in the last patch. diff --git a/globals.h b/globals.h --- a/globals.h +++ b/globals.h @@ -139,20 +139,20 @@ WHERE char *SslClientCert INITVAL (NULL); WHERE char *SslEntropyFile INITVAL (NULL); WHERE char *SslCiphers INITVAL (NULL); #ifdef USE_SSL_GNUTLS 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; WHERE short TSSupported; WHERE char *Username; WHERE char *Visual; WHERE char *CurrentFolder; diff --git a/hdrline.c b/hdrline.c --- a/hdrline.c +++ b/hdrline.c @@ -615,19 +615,19 @@ snprintf (buf2, sizeof (buf2), "To %s", mutt_get_name (hdr->env->to)); else if (hdr->env->cc) snprintf (buf2, sizeof (buf2), "Cc %s", mutt_get_name (hdr->env->cc)); } mutt_format_s (dest, destlen, prefix, buf2); 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': if (hdr->env->from && hdr->env->from->mailbox) { strfcpy (buf2, mutt_addr_for_display (hdr->env->from), sizeof (buf2)); if ((p = strpbrk (buf2, "%@"))) *p = 0; @@ -663,23 +663,23 @@ else if (WithCrypto && hdr->security & ENCRYPT) ch = 'P'; else if (WithCrypto && hdr->security & SIGN) ch = 's'; else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY) 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; case 'X': { int count = mutt_count_body_parts (ctx, hdr); /* The recursion allows messages without depth to return 0. */ diff --git a/init.h b/init.h --- a/init.h +++ b/init.h @@ -3381,17 +3381,17 @@ ** For OpenSSL, see ciphers(1) for the syntax of the string. ** .pp ** For GnuTLS, this option will be used in place of "NORMAL" at the ** start of the priority string. See gnutls_priority_init(3) for the ** syntax and more details. (Note: GnuTLS version 2.1.7 or higher is ** 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 ** $$status_format. The first character is used when the mailbox is ** unchanged. The second is used when the mailbox has been changed, and ** it needs to be resynchronized. The third is used if the mailbox is in ** read-only mode, or if the mailbox will not be written when exiting ** that mailbox (You can toggle whether to write changes to a mailbox @@ -3565,17 +3565,17 @@ { "tmpdir", DT_PATH, R_NONE, UL &Tempdir, 0 }, /* ** .pp ** This variable allows you to specify where Mutt will place its ** temporary files needed for displaying and composing messages. If ** 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 ** first character is the one used when the mail is \fInot\fP addressed to your ** address. The second is used when you are the only ** recipient of the message. The third is when your address ** appears in the ``To:'' header field, but you are not the only recipient of ** the message. The fourth character is used when your diff --git a/status.c b/status.c --- a/status.c +++ b/status.c @@ -223,24 +223,22 @@ { i = option(OPTATTACHMSG) ? 3 : ((Context->readonly || Context->dontwrite) ? 2 : (Context->changed || /* deleted doesn't necessarily mean changed in IMAP */ (Context->magic != MUTT_IMAP && 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; } case 's': snprintf (fmt, sizeof (fmt), "%%%ss", prefix); snprintf (buf, buflen, fmt, get_sort_str (tmp, sizeof (tmp), Sort)); break;
signature.asc
Description: PGP signature