From acb338b38e3004891a4f2967df2fae7c65ca001b Mon Sep 17 00:00:00 2001 From: David Levine Date: Sun, 4 May 2014 21:51:52 -0500 Subject: [PATCH] Replaced use of norm_charmap() in mhshow and mhfixmsg with case-insensitive string comparison against the charset name. norm_charmap() is intended for use with result of nl_langinfo(), and didn't add much value here. --- uip/mhfixmsg.c | 16 ++++++---------- uip/mhshowsbr.c | 14 +------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 069e3284..7705e6c8 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -1163,12 +1163,9 @@ reformat_part (CT ct, char *file, char *type, char *subtype, int c_type) { /* Identifies 7bit or 8bit content based on charset. */ static int charset_encoding (CT ct) { - /* norm_charmap() is case sensitive. */ - char *charset = upcase (content_charset (ct)); int encoding = - strcmp (norm_charmap (charset), "US-ASCII") ? CE_8BIT : CE_7BIT; + strcasecmp (content_charset (ct), "US-ASCII") ? CE_8BIT : CE_7BIT; - free (charset); return encoding; } @@ -1595,7 +1592,7 @@ content_encoding (CT ct, const char **reason) { static int strip_crs (CT ct, int *message_mods) { /* norm_charmap() is case sensitive. */ - char *charset = upcase (content_charset (ct)); + char *charset = content_charset (ct); int status = OK; /* Only strip carriage returns if content is ASCII or another @@ -1603,10 +1600,10 @@ strip_crs (CT ct, int *message_mods) { LF. We can include UTF-8 here because if the high-order bit of a UTF-8 byte is 0, then it must be a single-byte ASCII character. */ - if (! strcmp (norm_charmap (charset), "US-ASCII") || - ! strncmp (norm_charmap (charset), "ISO-8859-", 9) || - ! strncmp (norm_charmap (charset), "UTF-8", 5) || - ! strncmp (norm_charmap (charset), "WINDOWS-12", 10)) { + if (! strcasecmp (charset, "US-ASCII") || + ! strcasecmp (charset, "UTF-8") || + ! strncasecmp (charset, "ISO-8859-", 9) || + ! strncasecmp (charset, "WINDOWS-12", 10)) { char **file = NULL; FILE **fp = NULL; size_t begin; @@ -1730,7 +1727,6 @@ strip_crs (CT ct, int *message_mods) { } } - free (charset); return status; } diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 187f9156..8bd5f99a 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -1027,19 +1027,7 @@ convert_charset (CT ct, char *dest_charset, int *message_mods) { char *src_charset = content_charset (ct); int status = OK; - /* norm_charmap() is case sensitive. */ - char *src_charset_u = upcase (src_charset); - char *dest_charset_u = upcase (dest_charset); - char *src_charset_n = getcpy (norm_charmap (src_charset)); - char *dest_charset_n = getcpy (norm_charmap (dest_charset)); - int different_charsets = strcmp (src_charset_n, dest_charset_n); - - free (dest_charset_n); - free (src_charset_n); - free (dest_charset_u); - free (src_charset_u); - - if (different_charsets) { + if (strcasecmp (src_charset, dest_charset)) { #ifdef HAVE_ICONV iconv_t conv_desc = NULL; char *dest; -- 2.56.0