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

Re: [PATCH] always use iconv-hook (Re: What should go into 1.5.7?)



I'd like to hear Edmund Evans' opinion on this one.  Deferred until
1.5.8.  (Feb 11)
-- 
Thomas Roessler · Personal soap box at <http://log.does-not-exist.org/>.






On 2005-01-27 17:17:17 +0900, TAKAHASHI Tamotsu wrote:
> From: TAKAHASHI Tamotsu <ttakah@xxxxxxxxxxxxxxxxx>
> To: mutt-dev@xxxxxxxx
> Date: Thu, 27 Jan 2005 17:17:17 +0900
> Subject: [PATCH] always use iconv-hook (Re: What should go into 1.5.7?)
> Mail-Followup-To: mutt-dev@xxxxxxxx
> X-Spam-Level: 
> 
> [bug] Iconv-hook has no effect if an already-existing charset is given
> as a first argument.
> 
> 
> 
> [purpose] Some iconv implementation has eucJP-ms, which has more
> characters than euc-jp. So some users may want to do
> 
>       iconv-hook euc-jp eucJP-ms
> 
> to overwrite euc-jp. This patch allows you to do so.
> 
> 
> 
> [cons] No side effects found so far.
> This patch has been used since mutt-1.5.4 days.
> 
> 
> 
> [credit] The first author of this patch was:
> "MORIYAMA, Masayuki" (Fri, 11 Jul 2003 22:37:50 +0900)
> (he is an expert on charsets field in Japan.)
> 
> -- 
> tamo

> Some iconv implementation has eucJP-ms, which has more characters
> than euc-jp. So some users may want to do 'iconv-hook euc-jp eucJP-ms'
> to overwrite euc-jp. This patch allows you to do so.
> 
> --- mutt-1.5.6.orig/PATCHES   Mon Feb  2 02:42:47 2004
> +++ mutt-1.5.6/PATCHES        Sat Feb 14 10:02:10 2004
> @@ -0,0 +1 @@
> +patch-1.5.6.msyk+tamo.iconv.1
> --- mutt-1.5.6.orig/charset.c Tue Jan 21 21:25:21 2003
> +++ mutt-1.5.6/charset.c      Sat Feb 14 10:02:03 2004
> @@ -196,6 +196,7 @@
>    /* seems to be common on some systems */
>  
>    { "sjis",          "Shift_JIS"     },
> +  { "euc-jp-ms",     "eucJP-ms"      },
>  
>  
>    /*
> @@ -325,10 +325,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;
>  }
> --- mutt-1.5.6.orig/mbyte.c   Tue Jan 21 21:25:21 2003
> +++ mutt-1.5.6/mbyte.c        Sat Feb 14 10:01:29 2004
> @@ -67,10 +67,10 @@
>      Charset_is_utf8 = 1;
>  #ifndef HAVE_WC_FUNCS
>    else if (!strcmp(buffer, "euc-jp") || !strcmp(buffer, "shift_jis")
> -     || !strcmp(buffer, "cp932"))
> +     || !strcmp(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
>  
> --- mutt-1.5.4.orig/hook.c  Tue Jan 21 21:25:21 2003
> +++ mutt-1.5.4/hook.c   Sun May 11 16:08:16 2003
> @@ -88,7 +88,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))
>        )
>    {
> @@ -157,7 +157,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 */