X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=charset.c;h=29aa77662b3e9d208e7af623fddefb83529c340e;hp=cd672b584b85961553e56034d65fce762b61979b;hb=124aee0f600ef550fd1c73e8d7a60556f4f6afd0;hpb=b63368f0655c887d6a080faffdc462c0407f03f1 diff --git a/charset.c b/charset.c index cd672b5..29aa776 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" @@ -98,6 +81,11 @@ void charset_canonicalize(char *dest, ssize_t dlen, const char *name) 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== '.') { @@ -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[SHORT_STRING]; + charset_canonicalize(buf, sizeof(buf), s); + return !strcmp(buf, "utf-8"); } int charset_is_us_ascii(const char *s) { - return mutt_chscmp(s, "us-ascii"); + char buf[SHORT_STRING]; + charset_canonicalize(buf, sizeof(buf), s); + return !strcmp(buf, "us-ascii"); }