X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Fhdrline.c;h=4f5e5e41b6b76f3d8d98782c95c2723d572642e6;hp=92e6fa628254cb96a8c0c900b56563f248668430;hb=5dcac54e5db074dc4572f843666c7f7acaf2d109;hpb=b23d5033080fe9f9fba038e3cf1e3ec2b0a0d33d diff --git a/lib-ui/hdrline.c b/lib-ui/hdrline.c index 92e6fa6..4f5e5e4 100644 --- a/lib-ui/hdrline.c +++ b/lib-ui/hdrline.c @@ -7,18 +7,17 @@ * please see the file GPL in the top level source directory. */ -#include +#include #include -#include #include #include "mutt.h" #include "alias.h" +#include "crypt.h" #include "sort.h" #include "thread.h" #include "charset.h" -#include #include "mutt_idna.h" int mutt_is_mail_list (address_t * addr) @@ -220,7 +219,7 @@ hdr_format_str(char *dest, ssize_t destlen, HEADER *hdr, *htmp; CONTEXT *ctx; char fmt[STRING], buf2[STRING], ch, *p; - int do_locales, i; + int do_locales, i, c; int optional = (flags & M_FORMAT_OPTIONAL); int threads = ((Sort & SORT_MASK) == SORT_THREADS); int is_index = (flags & M_FORMAT_INDEX); @@ -498,7 +497,7 @@ hdr_format_str(char *dest, ssize_t destlen, case 'O': if (!optional) { make_from_addr (hdr->env, buf2, sizeof (buf2), 1); - if (!option (OPTSAVEADDRESS) && (p = strpbrk (buf2, "%@"))) + if ((p = strpbrk (buf2, "%@"))) *p = 0; mutt_format_s (dest, destlen, prefix, buf2); } @@ -576,11 +575,26 @@ hdr_format_str(char *dest, ssize_t destlen, break; case 'T': - snprintf (fmt, sizeof (fmt), "%%%sc", prefix); - snprintf (dest, destlen, fmt, - (Tochars - && ((i = mutt_user_is_recipient (hdr))) < - m_strlen(Tochars)) ? Tochars[i] : ' '); + i = mutt_user_is_recipient(hdr); + assert (i >= 0); /* help compiler to see c is initialized */ + + if (Charset_is_utf8) { + const char *s = Tochars; + + snprintf (fmt, sizeof (fmt), "%%%slc", prefix); + while (i-- >= 0) { + c = m_ustrgetc(s, &s); + if (c <= 0) { + c = ' '; + break; + } + } + + snprintf(dest, destlen, fmt, c); + } else { + snprintf(fmt, sizeof (fmt), "%%%sc", prefix); + snprintf(dest, destlen, fmt, i < m_strlen(Tochars) ? Tochars[i] : ' '); + } break; case 'u': @@ -647,18 +661,38 @@ hdr_format_str(char *dest, ssize_t destlen, else if (hdr->security & PGPKEY) ch = 'K'; - snprintf(buf2, sizeof (buf2), "%c%c%c", + if (hdr->tagged) { + c = '*'; + } else + if (hdr->flagged) { + c = '!'; + } else { + i = mutt_user_is_recipient(hdr); + assert (i >= 0); /* help compiler to see c is initialized */ + + if (Charset_is_utf8) { + const char *s = Tochars; + + snprintf (fmt, sizeof (fmt), "%%%slc", prefix); + while (i-- >= 0) { + c = m_ustrgetc(s, &s); + if (c <= 0) { + c = ' '; + break; + } + } + } else { + c = i < m_strlen(Tochars) ? Tochars[i] : ' '; + } + } + snprintf(buf2, sizeof (buf2), Charset_is_utf8 ? "%c%c%lc" : "%c%c%c", (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)) < m_strlen(Tochars)) - ? Tochars[i] : ' '))); + hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch), c); mutt_format_s (dest, destlen, prefix, buf2); break;