<<< Date Index >>>     <<< Thread Index >>>

For 1.5.9: iconv-hook patch by Moriyama-san



Here is the iconv-hook patch by MORIYAMA Masayuki.

This allows users to do
        "iconv-hook iso-2022-jp iso-2022-jp-ms"
even when iso-2022-jp is available.
That is useful because buggy MUAs send
iso-2022-jp-ms messages as "iso-2022-jp".

-- 
tamo
Index: PATCHES
===================================================================
RCS file: /home/roessler/cvs/mutt/PATCHES,v
retrieving revision 3.6
diff -u -u -r3.6 PATCHES
--- PATCHES     9 Dec 2002 17:44:54 -0000       3.6
+++ PATCHES     13 Feb 2005 05:39:49 -0000
@@ -0,0 +1 @@
+patch-1.5.8.msyk.iconvhook.1
Index: charset.c
===================================================================
RCS file: /home/roessler/cvs/mutt/charset.c,v
retrieving revision 3.9
diff -u -u -r3.9 charset.c
--- charset.c   12 Feb 2005 19:52:28 -0000      3.9
+++ charset.c   13 Feb 2005 05:39:50 -0000
@@ -329,10 +329,13 @@
   if ((flags & M_ICONV_HOOK_FROM) && (tmp = mutt_charset_hook (fromcode1)))
     mutt_canonical_charset (fromcode1, sizeof (fromcode1), tmp);
 
-  if ((cd = iconv_open (tocode1, fromcode1)) != (iconv_t) -1)
+  tocode2 = mutt_iconv_hook (tocode1);
+  tocode2 = (tocode2) ? tocode2 : tocode1;
+  fromcode2 = mutt_iconv_hook (fromcode1);
+  fromcode2 = (fromcode2) ? fromcode2 : fromcode1;
+
+  if ((cd = iconv_open (tocode2, fromcode2)) != (iconv_t) -1)
     return cd;
-  if ((tocode2 = mutt_iconv_hook (tocode1)) && (fromcode2 = mutt_iconv_hook 
(fromcode1)))
-    return iconv_open (tocode2, fromcode2);
   
   return (iconv_t) -1;
 }
Index: hook.c
===================================================================
RCS file: /home/roessler/cvs/mutt/hook.c,v
retrieving revision 3.10
diff -u -u -r3.10 hook.c
--- hook.c      3 Feb 2005 17:01:43 -0000       3.10
+++ hook.c      13 Feb 2005 05:39:52 -0000
@@ -92,7 +92,7 @@
     memset (&pattern, 0, sizeof (pattern));
     pattern.data = safe_strdup (path);
   }
-  else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
+  else if (DefaultHook && !(data & (M_CHARSETHOOK|M_ICONVHOOK|M_ACCOUNTHOOK))
            && (!WithCrypto || !(data & M_CRYPTHOOK))
       )
   {
@@ -161,7 +161,7 @@
   {
     rx = safe_malloc (sizeof (regex_t));
 #ifdef M_CRYPTHOOK
-    if ((rc = REGCOMP (rx, NONULL(pattern.data), ((data & 
(M_CRYPTHOOK|M_CHARSETHOOK)) ? REG_ICASE : 0))) != 0)
+    if ((rc = REGCOMP (rx, NONULL(pattern.data), ((data & 
(M_CRYPTHOOK|M_CHARSETHOOK|M_ICONVHOOK)) ? REG_ICASE : 0))) != 0)
 #else
     if ((rc = REGCOMP (rx, NONULL(pattern.data), (data & 
(M_CHARSETHOOK|M_ICONVHOOK)) ? REG_ICASE : 0)) != 0)
 #endif /* M_CRYPTHOOK */
Index: mbyte.c
===================================================================
RCS file: /home/roessler/cvs/mutt/mbyte.c,v
retrieving revision 3.4
diff -u -u -r3.4 mbyte.c
--- mbyte.c     12 Feb 2005 19:52:28 -0000      3.4
+++ mbyte.c     13 Feb 2005 05:39:54 -0000
@@ -71,8 +71,8 @@
        || !ascii_strcasecmp(buffer, "cp932") || !ascii_strcasecmp(buffer, 
"eucJP-ms"))
   {
     charset_is_ja = 1;
-    charset_to_utf8 = iconv_open ("UTF-8", charset);
-    charset_from_utf8 = iconv_open (charset, "UTF-8");
+    charset_to_utf8 = mutt_iconv_open ("UTF-8", charset, 0);
+    charset_from_utf8 = mutt_iconv_open (charset, "UTF-8", 0);
   }
 #endif