From c388c17c24294bc04139eaaf6da4dfdb16e03b37 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 31 Dec 2016 16:16:39 +0000 Subject: [PATCH] sync Fromchars to upstream version --- globals.h | 2 +- hdrline.c | 46 ++-------------------------------------------- init.h | 2 +- 3 files changed, 4 insertions(+), 46 deletions(-) diff --git a/globals.h b/globals.h index d796dab02..1f86d7d10 100644 --- a/globals.h +++ b/globals.h @@ -54,7 +54,7 @@ WHERE char *EscChar; WHERE char *FolderFormat; WHERE char *ForwFmt; WHERE char *Fqdn; -WHERE char *Fromchars; +WHERE mbchar_table *Fromchars; WHERE char *HdrFmt; WHERE char *HistFile; WHERE char *Homedir; diff --git a/hdrline.c b/hdrline.c index b78e50d79..cb538af57 100644 --- a/hdrline.c +++ b/hdrline.c @@ -139,44 +139,6 @@ add_index_color (char *buf, size_t buflen, format_flag flags, char color) return 2; } -/** - * get_nth_wchar - Extract one char from a utf-8 string - * @ustr: Unicode string - * @index: Select this character - * @return: String pointer to the character - * - * Extract one multi-byte character from a string. - * If the (index < 0) the first character will be selected. - * If the index is larger thant the string, then " " will be returned. - * If the character selected is '\n' (Ctrl-M), then "" will be returned. - * - * Note: get_nth_wchar() may return a pointer to a static buffer. - */ -char *get_nth_wchar (char *ustr, int index) -{ - static char buffer[5]; - int clen = 0; - int i; - - if (!*ustr) - return " "; - - for (i = 0; i <= index; i++) - { - ustr += clen; - clen = mutt_charlen (ustr, NULL); - if (clen < 1) - return " "; - } - - if ((clen == 1) && (ustr[0] == '\r')) - return ""; - - memcpy (buffer, ustr, clen); - buffer[clen] = 0; - return buffer; -} - enum FieldType { DISP_TO, @@ -205,14 +167,10 @@ static const char *make_from_prefix(enum FieldType disp) [DISP_FROM] = "" }; - if (!Fromchars || (*Fromchars == '\0')) + if (!Fromchars || (disp >= Fromchars->len)) return long_prefixes[disp]; - char *prefix = get_nth_wchar (Fromchars, disp); - if (!prefix || (prefix[0] == '\0')) - return prefix; - - snprintf (padded, sizeof(padded), "%s ", prefix); + snprintf (padded, sizeof(padded), "%s ", Fromchars->chars[disp]); return padded; } diff --git a/init.h b/init.h index 4f502418d..267501468 100644 --- a/init.h +++ b/init.h @@ -1006,7 +1006,7 @@ struct option_t MuttVars[] = { ** .pp ** This setting defaults to the contents of the environment variable \fC$$$EMAIL\fP. */ - { "from_chars", DT_STR, R_BOTH, UL &Fromchars, UL 0 }, + { "from_chars", DT_MBCHARTBL, R_BOTH, UL &Fromchars, 0 }, /* ** .pp ** Controls the character used to prefix the %F and %L fields in the -- 2.50.1