? autom4te-2.53.cache
? gmime.patch
? simex.c
? simex.h
? gmime/host.c
? gmime/host.h
? gmime/utils.c
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gmime/ChangeLog,v
retrieving revision 1.426
diff -u -r1.426 ChangeLog
--- ChangeLog	30 Mar 2004 14:10:33 -0000	1.426
+++ ChangeLog	30 Mar 2004 22:15:19 -0000
@@ -1,5 +1,9 @@
 2004-03-30  Jeffrey Stedfast  <fejj@ximian.com>
 
+	* gmime/gmime-charset.c (charset_best_mask): Don't use the charset
+	if it is lang specific and the lang doesn't match the
+	locale. Fixes bug #138218.
+
 	* gmime/gmime-utils.c (mktime_utc): New function to mktime() into
 	UTC.
 	(parse_rfc822_date): Use mktime_utc() instead of doing it
Index: gmime/gmime-charset.c
===================================================================
RCS file: /cvs/gnome/gmime/gmime/gmime-charset.c,v
retrieving revision 1.29
diff -u -r1.29 gmime-charset.c
--- gmime/gmime-charset.c	9 Mar 2004 15:30:15 -0000	1.29
+++ gmime/gmime-charset.c	30 Mar 2004 22:15:20 -0000
@@ -121,6 +121,7 @@
 	{ "gbk",         "zh" },
 	{ "euc-tw",      "zh" },
 	{ "iso-2022-jp", "ja" },
+	{ "Shift-JIS",   "ja" },
 	{ "sjis",        "ja" },
 	{ "ujis",        "ja" },
 	{ "eucJP",       "ja" },
@@ -130,9 +131,6 @@
 	{ "koi8-u",      "uk" }
 };
 
-#define NUM_CJKR_LANGS (sizeof (cjkr_lang_map) / sizeof (cjkr_lang_map[0]))
-
-
 static GHashTable *iconv_charsets = NULL;
 static char *locale_charset = NULL;
 static char *locale_lang = NULL;
@@ -347,7 +345,7 @@
 	if (!charset)
 		return NULL;
 	
-	for (i = 0; i < NUM_CJKR_LANGS; i++) {
+	for (i = 0; i < G_N_ELEMENTS (cjkr_lang_map); i++) {
 		if (!strcasecmp (cjkr_lang_map[i].charset, charset))
 			return cjkr_lang_map[i].lang;
 	}
@@ -484,8 +482,6 @@
 	"iso-8859-16"
 };
 
-#define NUM_ISO_CHARSETS (sizeof (iso_charsets) / sizeof (iso_charsets[0]))
-
 static const char *windows_charsets[] = {
 	"windows-cp1250",
 	"windows-cp1251",
@@ -540,7 +536,7 @@
 		if (endptr == ptr || *endptr != '\0')
 			return charset;
 		
-		if (iso >= NUM_ISO_CHARSETS)
+		if (iso > G_N_ELEMENTS (iso_charsets))
 			return charset;
 		
 		return iso_charsets[iso];
@@ -718,11 +714,16 @@
 static const char *
 charset_best_mask (unsigned int mask)
 {
+	const char *lang;
 	int i;
 	
-	for (i = 0; i < sizeof (charinfo) / sizeof (charinfo[0]); i++) {
-		if (charinfo[i].bit & mask)
-			return charinfo[i].name;
+	for (i = 0; i < G_N_ELEMENTS (charinfo); i++) {
+		if (charinfo[i].bit & mask) {
+			lang = g_mime_charset_language (charinfo[i].name);
+			
+			if (!lang || (locale_lang && !strncmp (locale_lang, lang, 2)))
+				return charinfo[i].name;
+		}
 	}
 	
 	return "UTF-8";
