From 10f5ca3e65a56d7e52c0d3b41652e3dabee3cecd Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 27 Dec 2016 15:23:37 -0800 Subject: [PATCH] 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 commit. --- globals.h | 4 ++-- hdrline.c | 12 ++++++------ init.h | 4 ++-- status.c | 10 ++++------ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/globals.h b/globals.h index 30ad4413..ebcc4789 100644 --- 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; diff --git a/hdrline.c b/hdrline.c index 2d44de34..10248469 100644 --- 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 aacc492e..6d23e2d5 100644 --- 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 diff --git a/status.c b/status.c index 52baa8c1..b19fb412 100644 --- 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; } -- 2.40.0