X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=charset.c;h=11441e4a8f8918fdcd5c48c272f7fd858f33458e;hp=cd672b584b85961553e56034d65fce762b61979b;hb=b1c9f537b475b3bc8f6517bb4d7008a411bb478e;hpb=b63368f0655c887d6a080faffdc462c0407f03f1 diff --git a/charset.c b/charset.c index cd672b5..11441e4 100644 --- a/charset.c +++ b/charset.c @@ -25,29 +25,12 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include - -#include +#include -#include -#include -#include -#include #ifdef HAVE_LANGINFO_CODESET # include #endif -#include -#include -#include -#include - #include "mutt.h" #include "charset.h" @@ -67,8 +50,8 @@ wchar_t CharsetReplacement = '?'; void charset_initialize(void) { #ifdef HAVE_LANGINFO_CODESET - char buff[SHORT_STRING]; - char buff2[SHORT_STRING]; + char buff[STRING]; + char buff2[STRING]; m_strcpy(buff, sizeof(buff), nl_langinfo(CODESET)); charset_canonicalize(buff2, sizeof(buff2), buff); @@ -82,7 +65,7 @@ void charset_initialize(void) m_strreplace(&Charset, "iso-8859-1"); } - Charset_is_utf8 = !strcmp(Charset, "utf-8"); + Charset_is_utf8 = !m_strcmp(Charset, "utf-8"); CharsetReplacement = Charset_is_utf8 ? 0xfffd : '?'; #ifdef HAVE_BIND_TEXTDOMAIN_CODESET @@ -94,10 +77,15 @@ void charset_initialize(void) void charset_canonicalize(char *dest, ssize_t dlen, const char *name) { const struct cset_pair *cp; - char scratch[SHORT_STRING]; + char scratch[STRING]; const char *p; int i = 0; + if (!name) { + m_strcpy(dest, dlen, "us-ascii"); + return; + } + // canonize name: only keep a-z0-9 and dots, put into lowercase for (p = name; *p && *p != ':' && i < ssizeof(scratch) - 1; p++) { if (isalnum(*p) || *p== '.') { @@ -118,7 +106,7 @@ void charset_canonicalize(char *dest, ssize_t dlen, const char *name) /* XXX: MC: UGLY return of local static */ const char *charset_getfirst(const char *charset) { - static char fcharset[SHORT_STRING]; + static char fcharset[STRING]; const char *p; if (m_strisempty(charset)) @@ -129,25 +117,18 @@ const char *charset_getfirst(const char *charset) return fcharset; } -static int mutt_chscmp(const char *s, const char *chs) -{ - char buffer[SHORT_STRING]; - - if (!s) - return 0; - - charset_canonicalize(buffer, sizeof(buffer), s); - return !strcmp(buffer, chs); -} - int charset_is_utf8(const char *s) { - return mutt_chscmp(s, "utf-8"); + char buf[STRING]; + charset_canonicalize(buf, sizeof(buf), s); + return !m_strcmp(buf, "utf-8"); } int charset_is_us_ascii(const char *s) { - return mutt_chscmp(s, "us-ascii"); + char buf[STRING]; + charset_canonicalize(buf, sizeof(buf), s); + return !m_strcmp(buf, "us-ascii"); } @@ -158,8 +139,8 @@ int charset_is_us_ascii(const char *s) /* Like iconv_open, but canonicalises the charsets */ iconv_t mutt_iconv_open(const char *tocode, const char *fromcode, int flags) { - char tocode1[SHORT_STRING]; - char fromcode1[SHORT_STRING]; + char tocode1[STRING]; + char fromcode1[STRING]; const char *tmp; iconv_t cd;