sync with 0.8.8cvs5
authorPaul Mangan <paul@claws-mail.org>
Sun, 12 Jan 2003 17:59:21 +0000 (17:59 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sun, 12 Jan 2003 17:59:21 +0000 (17:59 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/about.c
src/codeconv.c
src/codeconv.h
src/imap.c
src/mainwindow.c
src/prefs_common.c

index 5ae4388..5051813 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-01-13
+
+       * src/codeconv.[ch]: made the transition from libjconv to iconv().
+         conv_iconv_strdup(): new.
+       * src/about.c
+         src/imap.c
+         src/mainwindow.c
+         src/prefs_common.c: replaced HAVE_LIBJCONV to HAVE_ICONV.
+
 2003-01-10
 
        * src/compose.c
index d03194a..06944e4 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-12 [paul]      0.8.8claws86
+
+       * sync with 0.8.8cvs5
+               see ChangeLog 2002-01-13 (!)
+
 2002-01-12 [alfons]    0.8.8claws85
 
        * src/filtering.c
index 1f20315..c151e5b 100644 (file)
@@ -1,3 +1,12 @@
+2003-01-13
+
+       * src/codeconv.[ch]: libjconv ¤«¤é iconv() ¤Ø°Ü¹Ô¡£
+         conv_iconv_strdup(): ¿·µ¬¡£
+       * src/about.c
+         src/imap.c
+         src/mainwindow.c
+         src/prefs_common.c: HAVE_LIBJCONV ¤ò HAVE_ICONV ¤ËÃÖ´¹¡£
+
 2003-01-10
 
        * src/compose.c
index 278a6a4..d2d44c6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws85
+EXTRA_VERSION=claws86
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
@@ -194,14 +194,6 @@ fi
 dnl Check for OpenSSL
 AM_PATH_OPENSSL
 
-dnl Check for libjconv
-AC_ARG_ENABLE(jconv,
-       [  --disable-jconv         Do not use libjconv],
-       [ac_cv_enable_jconv=$enableval], [ac_cv_enable_jconv=yes])
-if test "$ac_cv_enable_jconv" = yes; then
-       AC_CHECK_LIB(jconv, jconv_alloc_conv,,[ac_cv_enable_jconv=no])
-fi
-
 dnl ************************
 dnl ** GTK user interface **
 dnl ************************
@@ -443,7 +435,6 @@ echo "JPilot        : $ac_cv_enable_jpilot"
 echo "LDAP          : $ac_cv_enable_ldap"
 echo "OpenSSL       : $ac_cv_enable_openssl"
 echo "compface      : $ac_cv_enable_compface"
-echo "libjconv      : $ac_cv_enable_jconv"
 echo "IPv6          : $ac_cv_enable_ipv6"
 echo "GNU/aspell    : $ac_cv_enable_aspell"
 echo "Crash dialog  : $ac_cv_enable_crash_dialog"
index c2d847c..d1c817e 100644 (file)
 
 #include "intl.h"
 #include "about.h"
+#include "gtkutils.h"
 #include "stock_pixmap.h"
 #include "prefs_common.h"
 #include "utils.h"
 #include "version.h"
-#include "gtkutils.h"
 
 static GtkWidget *window;
 
@@ -136,12 +136,12 @@ static void about_create(void)
 #if INET6
                   " IPv6"
 #endif
+#if HAVE_ICONV
+                  " iconv"
+#endif
 #if HAVE_LIBCOMPFACE
                   " compface"
 #endif
-#if HAVE_LIBJCONV
-                  " jconv"
-#endif
 #if USE_GPGME
                   " GnuPG"
 #endif
index 1b9dfcf..6d0a7a1 100644 (file)
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #if HAVE_LOCALE_H
 #  include <locale.h>
 #endif
 
-#if HAVE_LIBJCONV
-#  include <jconv.h>
+#if HAVE_ICONV
+#  include <iconv.h>
 #endif
 
 #include "intl.h"
@@ -551,7 +552,7 @@ void conv_code_converter_destroy(CodeConverter *conv)
 gint conv_convert(CodeConverter *conv, gchar *outbuf, gint outlen,
                  const gchar *inbuf)
 {
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        if (conv->code_conv_func != conv_noconv)
                conv->code_conv_func(outbuf, outlen, inbuf);
        else {
@@ -565,7 +566,7 @@ gint conv_convert(CodeConverter *conv, gchar *outbuf, gint outlen,
                        g_free(str);
                }
        }
-#else /* !HAVE_LIBJCONV */
+#else /* !HAVE_ICONV */
        conv->code_conv_func(outbuf, outlen, inbuf);
 #endif
 
@@ -573,18 +574,13 @@ gint conv_convert(CodeConverter *conv, gchar *outbuf, gint outlen,
 }
 
 gchar *conv_codeset_strdup(const gchar *inbuf,
-                          const gchar *src_codeset, const gchar *dest_codeset)
+                          const gchar *src_code, const gchar *dest_code)
 {
        gchar *buf;
        size_t len;
        CodeConvFunc conv_func;
-#if HAVE_LIBJCONV
-       gint actual_codeset;
-       const gchar *const *codesets;
-       gint n_codesets;
-#endif
 
-       conv_func = conv_get_code_conv_func(src_codeset, dest_codeset);
+       conv_func = conv_get_code_conv_func(src_code, dest_code);
        if (conv_func != conv_noconv) {
                len = (strlen(inbuf) + 1) * 3;
                buf = g_malloc(len);
@@ -594,40 +590,24 @@ gchar *conv_codeset_strdup(const gchar *inbuf,
                return g_realloc(buf, strlen(buf) + 1);
        }
 
-#if !HAVE_LIBJCONV
-       return g_strdup(inbuf);
-#else
-       /* don't convert if src and dest codeset are identical */
-       if (src_codeset && dest_codeset &&
-           !strcasecmp(src_codeset, dest_codeset))
+#if HAVE_ICONV
+       if (!src_code)
+               src_code = conv_get_outgoing_charset_str();
+       if (!dest_code)
+               dest_code = conv_get_current_charset_str();
+
+       /* don't convert if current codeset is US-ASCII */
+       if (!strcasecmp(dest_code, CS_US_ASCII))
                return g_strdup(inbuf);
 
-       if (src_codeset) {
-               codesets = &src_codeset;
-               n_codesets = 1;
-       } else
-               codesets = jconv_info_get_pref_codesets(&n_codesets);
-       if (!dest_codeset) {
-               dest_codeset = conv_get_current_charset_str();
-               /* don't convert if current codeset is US-ASCII */
-               if (!strcasecmp(dest_codeset, CS_US_ASCII))
-                       return g_strdup(inbuf);
-       }
+       /* don't convert if src and dest codeset are identical */
+       if (!strcasecmp(src_code, dest_code))
+               return g_strdup(inbuf);
 
-       if (jconv_alloc_conv(inbuf, strlen(inbuf), &buf, &len,
-                            codesets, n_codesets,
-                            &actual_codeset, dest_codeset)
-           == 0)
-               return buf;
-       else {
-#if 0
-               g_warning("code conversion from %s to %s failed\n",
-                         codesets && codesets[0] ? codesets[0] : "(unknown)",
-                         dest_codeset);
-#endif /* 0 */
-               return NULL;
-       }
-#endif /* HAVE_LIBJCONV */
+       return conv_iconv_strdup(inbuf, src_code, dest_code);
+#else
+       return g_strdup(inbuf);
+#endif /* HAVE_ICONV */
 }
 
 CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
@@ -665,7 +645,7 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
                        code_conv = conv_ustodisp;
                break;
        case C_ISO_8859_1:
-#if !HAVE_LIBJCONV
+#if !HAVE_ICONV
        case C_ISO_8859_2:
        case C_ISO_8859_4:
        case C_ISO_8859_5:
@@ -699,6 +679,61 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
        return code_conv;
 }
 
+#if HAVE_ICONV
+gchar *conv_iconv_strdup(const gchar *inbuf,
+                        const gchar *src_code, const gchar *dest_code)
+{
+       iconv_t cd;
+       const gchar *inbuf_p;
+       gchar *outbuf;
+       gchar *outbuf_p;
+       gint in_size;
+       gint in_left;
+       gint out_size;
+       gint out_left;
+       gint n_conv;
+
+       cd = iconv_open(dest_code, src_code);
+       if (cd == (iconv_t)-1)
+               return NULL;
+
+       inbuf_p = inbuf;
+       in_size = strlen(inbuf) + 1;
+       in_left = in_size;
+       out_size = in_size * 2;
+       outbuf = g_malloc(out_size);
+       outbuf_p = outbuf;
+       out_left = out_size;
+
+       while ((n_conv = iconv(cd, (gchar **)&inbuf_p, &in_left,
+                              &outbuf_p, &out_left)) < 0) {
+               if (EILSEQ == errno) {
+                       *outbuf_p = '\0';
+                       break;
+               } else if (EINVAL == errno) {
+                       *outbuf_p = '\0';
+                       break;
+               } else if (E2BIG == errno) {
+                       out_size *= 2;
+                       outbuf = g_realloc(outbuf, out_size);
+                       inbuf_p = inbuf;
+                       in_left = in_size;
+                       outbuf_p = outbuf;
+                       out_left = out_size;
+               } else {
+                       g_warning("conv_iconv_strdup(): %s\n",
+                                 g_strerror(errno));
+                       *outbuf_p = '\0';
+                       break;
+               }
+       }
+
+       iconv_close(cd);
+
+       return outbuf;
+}
+#endif /* HAVE_ICONV */
+
 static const struct {
        CharSet charset;
        gchar *const name;
@@ -739,7 +774,6 @@ static const struct {
        {C_WINDOWS_874,         CS_WINDOWS_874},
 };
 
-#if !HAVE_LIBJCONV
 static const struct {
        gchar *const locale;
        CharSet charset;
@@ -804,7 +838,6 @@ static const struct {
        {"POSIX"                , C_US_ASCII    , C_US_ASCII},
        {"ANSI_X3.4-1968"       , C_US_ASCII    , C_US_ASCII},
 };
-#endif /* !HAVE_LIBJCONV */
 
 const gchar *conv_get_charset_str(CharSet charset)
 {
@@ -835,26 +868,12 @@ CharSet conv_get_charset_from_str(const gchar *charset)
 CharSet conv_get_current_charset(void)
 {
        static CharSet cur_charset = -1;
-       gint i;
-
-#if HAVE_LIBJCONV
-       const gchar *cur_codeset;
-#else
        const gchar *cur_locale;
-#endif
+       gint i;
 
        if (cur_charset != -1)
                return cur_charset;
 
-#if HAVE_LIBJCONV
-       cur_codeset = jconv_info_get_current_codeset();
-       for (i = 0; i < sizeof(charsets) / sizeof(charsets[0]); i++) {
-               if (!strcasecmp(cur_codeset, charsets[i].name)) {
-                       cur_charset = charsets[i].charset;
-                       return cur_charset;
-               }
-       }
-#else
        cur_locale = conv_get_current_locale();
        if (!cur_locale) {
                cur_charset = C_US_ASCII;
@@ -869,8 +888,8 @@ CharSet conv_get_current_charset(void)
        for (i = 0; i < sizeof(locale_table) / sizeof(locale_table[0]); i++) {
                const gchar *p;
 
-               /* "ja_JP.EUC" matches with "ja_JP.eucJP" and "ja_JP.EUC" */
-               /* "ja_JP" matches with "ja_JP.xxxx" and "ja" */
+               /* "ja_JP.EUC" matches with "ja_JP.eucJP", "ja_JP.EUC" and
+                  "ja_JP". "ja_JP" matches with "ja_JP.xxxx" and "ja" */
                if (!strncasecmp(cur_locale, locale_table[i].locale,
                                 strlen(locale_table[i].locale))) {
                        cur_charset = locale_table[i].charset;
@@ -884,7 +903,6 @@ CharSet conv_get_current_charset(void)
                        }
                }
        }
-#endif
 
        cur_charset = C_AUTO;
        return cur_charset;
@@ -903,39 +921,12 @@ const gchar *conv_get_current_charset_str(void)
 CharSet conv_get_outgoing_charset(void)
 {
        static CharSet out_charset = -1;
-       gint i;
-
-#if HAVE_LIBJCONV
-       gint j, n_pref_codesets;
-       const gchar *const *pref_codesets;
-#else
        const gchar *cur_locale;
-#endif
+       gint i;
 
        if (out_charset != -1)
                return out_charset;
 
-#if HAVE_LIBJCONV
-       /* skip US-ASCII and UTF-8 */
-       pref_codesets = jconv_info_get_pref_codesets(&n_pref_codesets);
-       for (i = 0; i < n_pref_codesets; i++) {
-               for (j = 3; j < sizeof(charsets) / sizeof(charsets[0]); j++) {
-                       if (!strcasecmp(pref_codesets[i], charsets[j].name)) {
-                               out_charset = charsets[j].charset;
-                               return out_charset;
-                       }
-               }
-       }
-
-       for (i = 0; i < n_pref_codesets; i++) {
-               if (!strcasecmp(pref_codesets[i], "UTF-8")) {
-                       out_charset = C_UTF_8;
-                       return out_charset;
-               }
-       }
-
-       out_charset = C_AUTO;
-#else
        cur_locale = conv_get_current_locale();
        if (!cur_locale) {
                out_charset = C_AUTO;
@@ -959,12 +950,13 @@ CharSet conv_get_outgoing_charset(void)
                }
        }
 
-       /* encoding conversion without libjconv is only supported
+#if !HAVE_ICONV
+       /* encoding conversion without iconv() is only supported
           on Japanese locale for now */
        if (out_charset == C_ISO_2022_JP)
                return out_charset;
-
-       out_charset = conv_get_current_charset();
+       else
+               return conv_get_current_charset();
 #endif
 
        return out_charset;
index 884bd66..892b198 100644 (file)
@@ -136,12 +136,18 @@ gint conv_convert                 (CodeConverter  *conv,
                                         const gchar    *inbuf);
 
 gchar *conv_codeset_strdup             (const gchar    *inbuf,
-                                        const gchar    *src_codeset,
-                                        const gchar    *dest_codeset);
+                                        const gchar    *src_code,
+                                        const gchar    *dest_code);
 
 CodeConvFunc conv_get_code_conv_func   (const gchar    *src_charset_str,
                                         const gchar    *dest_charset_str);
 
+#if HAVE_ICONV
+gchar *conv_iconv_strdup               (const gchar    *inbuf,
+                                        const gchar    *src_code,
+                                        const gchar    *dest_code);
+#endif
+
 const gchar *conv_get_charset_str              (CharSet         charset);
 CharSet conv_get_charset_from_str              (const gchar    *charset);
 CharSet conv_get_current_charset               (void);
index 7ec4baa..ba4ac76 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,8 +31,8 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <time.h>
-#if HAVE_LIBJCONV
-#  include <jconv.h>
+#if HAVE_ICONV
+#  include <iconv.h>
 #endif
 
 #include "intl.h"
@@ -3157,7 +3157,7 @@ static void imap_path_separator_subst(gchar *str, gchar separator)
 
 static gchar *imap_modified_utf7_to_locale(const gchar *mutf7_str)
 {
-#if !HAVE_LIBJCONV
+#if !HAVE_ICONV
        return g_strdup(mutf7_str);
 #else
        static iconv_t cd = (iconv_t)-1;
@@ -3225,12 +3225,12 @@ static gchar *imap_modified_utf7_to_locale(const gchar *mutf7_str)
        *to_p = '\0';
 
        return to_str;
-#endif /* !HAVE_LIBJCONV */
+#endif /* !HAVE_ICONV */
 }
 
 static gchar *imap_locale_to_modified_utf7(const gchar *from)
 {
-#if !HAVE_LIBJCONV
+#if !HAVE_ICONV
        return g_strdup(from);
 #else
        static iconv_t cd = (iconv_t)-1;
@@ -3321,7 +3321,7 @@ static gchar *imap_locale_to_modified_utf7(const gchar *from)
        g_string_free(to_str, FALSE);
 
        return to;
-#endif
+#endif /* !HAVE_ICONV */
 }
 
 static gboolean imap_rename_folder_func(GNode *node, gpointer data)
index 82c3dcf..d916278 100644 (file)
@@ -519,7 +519,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
         CODESET_ACTION(C_US_ASCII)},
 
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        {N_("/_View/_Code set/Unicode (_UTF-8)"),
         CODESET_ACTION(C_UTF_8)},
        CODESET_SEPARATOR,
@@ -529,7 +529,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Code set/Western European (ISO-8859-15)"),
         CODESET_ACTION(C_ISO_8859_15)},
        CODESET_SEPARATOR,
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
         CODESET_ACTION(C_ISO_8859_2)},
        CODESET_SEPARATOR,
@@ -554,7 +554,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
 #endif
        {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
         CODESET_ACTION(C_ISO_2022_JP)},
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
         CODESET_ACTION(C_ISO_2022_JP_2)},
 #endif
@@ -562,7 +562,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
         CODESET_ACTION(C_EUC_JP)},
        {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
         CODESET_ACTION(C_SHIFT_JIS)},
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        CODESET_SEPARATOR,
        {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
         CODESET_ACTION(C_GB2312)},
index b8a54e3..5bb3e39 100644 (file)
@@ -1366,7 +1366,7 @@ static void prefs_send_create(void)
 
        SET_MENUITEM(_("Automatic (Recommended)"),       CS_AUTO);
        SET_MENUITEM(_("7bit ascii (US-ASCII)"),         CS_US_ASCII);
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        SET_MENUITEM(_("Unicode (UTF-8)"),               CS_UTF_8);
 #endif
        SET_MENUITEM(_("Western European (ISO-8859-1)"),  CS_ISO_8859_1);
@@ -1376,11 +1376,11 @@ static void prefs_send_create(void)
        SET_MENUITEM(_("Baltic (ISO-8859-4)"),            CS_ISO_8859_4);
        SET_MENUITEM(_("Greek (ISO-8859-7)"),             CS_ISO_8859_7);
        SET_MENUITEM(_("Turkish (ISO-8859-9)"),           CS_ISO_8859_9);
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        SET_MENUITEM(_("Cyrillic (ISO-8859-5)"),          CS_ISO_8859_5);
 #endif
        SET_MENUITEM(_("Cyrillic (KOI8-R)"),             CS_KOI8_R);
-#if HAVE_LIBJCONV
+#if HAVE_ICONV
        SET_MENUITEM(_("Cyrillic (Windows-1251)"),       CS_WINDOWS_1251);
        SET_MENUITEM(_("Cyrillic (KOI8-U)"),             CS_KOI8_U);
 #endif