Enable the endianness test.
authorMatthias Clasen <mclasen@redhat.com>
Mon, 8 Aug 2005 19:50:38 +0000 (19:50 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 8 Aug 2005 19:50:38 +0000 (19:50 +0000)
2005-08-08  Matthias Clasen  <mclasen@redhat.com>

* tests/convert-test.c: Enable the endianness test.

* glib/gconvert.c: Make the caching of iconv descriptors
optional.

* configure.in: Add an --enable-iconv-cache option, and
default to disabling iconv caching on new enough glibc.
Somebody with access to Solaris systems will need to test
if opening/closing of iconv descriptors is enough of
a performance problem to warrant the caching on that
platform. Note that the caching is causing correctness
problems in some corner cases, thus turning it off
is desirable unless it has severe performance implications.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-8
configure.in
glib/gconvert.c
tests/convert-test.c

index d17cb9b..4b405fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2005-08-08  Matthias Clasen  <mclasen@redhat.com>
 
+       * tests/convert-test.c: Enable the endianness test.
+
+       * glib/gconvert.c: Make the caching of iconv descriptors
+       optional.
+
+       * configure.in: Add an --enable-iconv-cache option, and
+       default to disabling iconv caching on new enough glibc.
+       Somebody with access to Solaris systems will need to test
+       if opening/closing of iconv descriptors is enough of
+       a performance problem to warrant the caching on that 
+       platform. Note that the caching is causing correctness
+       problems in some corner cases, thus turning it off
+       is desirable unless it has severe performance implications.
+
        * tests/convert-test.c: Add a test for 
        endianness handling.
 
index d17cb9b..4b405fa 100644 (file)
@@ -1,5 +1,19 @@
 2005-08-08  Matthias Clasen  <mclasen@redhat.com>
 
+       * tests/convert-test.c: Enable the endianness test.
+
+       * glib/gconvert.c: Make the caching of iconv descriptors
+       optional.
+
+       * configure.in: Add an --enable-iconv-cache option, and
+       default to disabling iconv caching on new enough glibc.
+       Somebody with access to Solaris systems will need to test
+       if opening/closing of iconv descriptors is enough of
+       a performance problem to warrant the caching on that 
+       platform. Note that the caching is causing correctness
+       problems in some corner cases, thus turning it off
+       is desirable unless it has severe performance implications.
+
        * tests/convert-test.c: Add a test for 
        endianness handling.
 
index d17cb9b..4b405fa 100644 (file)
@@ -1,5 +1,19 @@
 2005-08-08  Matthias Clasen  <mclasen@redhat.com>
 
+       * tests/convert-test.c: Enable the endianness test.
+
+       * glib/gconvert.c: Make the caching of iconv descriptors
+       optional.
+
+       * configure.in: Add an --enable-iconv-cache option, and
+       default to disabling iconv caching on new enough glibc.
+       Somebody with access to Solaris systems will need to test
+       if opening/closing of iconv descriptors is enough of
+       a performance problem to warrant the caching on that 
+       platform. Note that the caching is causing correctness
+       problems in some corner cases, thus turning it off
+       is desirable unless it has severe performance implications.
+
        * tests/convert-test.c: Add a test for 
        endianness handling.
 
index d17cb9b..4b405fa 100644 (file)
@@ -1,5 +1,19 @@
 2005-08-08  Matthias Clasen  <mclasen@redhat.com>
 
+       * tests/convert-test.c: Enable the endianness test.
+
+       * glib/gconvert.c: Make the caching of iconv descriptors
+       optional.
+
+       * configure.in: Add an --enable-iconv-cache option, and
+       default to disabling iconv caching on new enough glibc.
+       Somebody with access to Solaris systems will need to test
+       if opening/closing of iconv descriptors is enough of
+       a performance problem to warrant the caching on that 
+       platform. Note that the caching is causing correctness
+       problems in some corner cases, thus turning it off
+       is desirable unless it has severe performance implications.
+
        * tests/convert-test.c: Add a test for 
        endianness handling.
 
index 77086e1..e79e873 100644 (file)
@@ -396,6 +396,34 @@ if test "x$found_iconv" = "xno" ; then
    AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
 fi
 
+jm_GLIBC21
+AC_ARG_ENABLE(iconv-cache, 
+              [AC_HELP_STRING([--enable-iconv-cache=@<:@yes/no/auto@:>@],
+                              [cache iconv descriptors [default=auto]])],,
+              [enable_iconv_cache=auto])
+
+AC_MSG_CHECKING([Whether to cache iconv descriptors])
+case $enable_iconv_cache in
+  auto)
+    if test $ac_cv_gnu_library_2_1 = yes; then
+      enable_iconv_cache=no
+    else 
+      enable_iconv_cache=yes
+    fi
+  ;;
+  yes|no) 
+  ;;
+  *) AC_MSG_ERROR([Value given to --enable-iconv-cache must be one of yes, no or auto])
+  ;;
+esac
+
+if test $enable_iconv_cache = yes; then
+   AC_DEFINE(NEED_ICONV_CACHE,1,[Do we cache iconv descriptors])
+fi
+
+AC_MSG_RESULT($enable_iconv_cache)
+
+
 dnl
 dnl gettext support
 dnl
index 4504fd8..bae23c4 100644 (file)
@@ -196,6 +196,8 @@ g_iconv_close (GIConv converter)
 }
 
 
+#ifdef NEED_ICONV_CACHE
+
 #define ICONV_CACHE_SIZE   (16)
 
 struct _iconv_cache_bucket {
@@ -463,6 +465,47 @@ close_converter (GIConv converter)
   return 0;
 }
 
+#else  /* !NEED_ICONV_CACHE */
+
+static GIConv
+open_converter (const gchar *to_codeset,
+               const gchar *from_codeset,
+               GError     **error)
+{
+  GIConv cd;
+
+  cd = g_iconv_open (to_codeset, from_codeset);
+
+  if (cd == (GIConv) -1)
+    {
+      /* Something went wrong.  */
+      if (error)
+       {
+         if (errno == EINVAL)
+           g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION,
+                        _("Conversion from character set '%s' to '%s' is not supported"),
+                        from_codeset, to_codeset);
+         else
+           g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
+                        _("Could not open converter from '%s' to '%s'"),
+                        from_codeset, to_codeset);
+       }
+    }
+  
+  return cd;
+}
+
+static int
+close_converter (GIConv cd)
+{
+  if (cd == (GIConv) -1)
+    return 0;
+  
+  return g_iconv_close (cd);  
+}
+
+#endif /* NEED_ICONV_CACHE */
+
 /**
  * g_convert_with_iconv:
  * @str:           the string to convert
index 2b7596f..bc47456 100644 (file)
@@ -106,7 +106,6 @@ test_byte_order (void)
   gsize bytes_read = 0;
   gsize bytes_written = 0;
   GError *error = NULL;  
-  int i;
 
   out = g_convert (in_be, sizeof (in_be), 
                   "UTF-8", "UTF-16",
@@ -125,7 +124,7 @@ test_byte_order (void)
                   &error);
 
   g_assert (error == NULL);
-  g_assert (bytes_read == 2);
+  g_assert (bytes_read == 4);
   g_assert (bytes_written == 2);
   g_assert (strcmp (out, expected) == 0);
   g_free (out);
@@ -136,13 +135,7 @@ main (int argc, char *argv[])
 {
   test_iconv_state ();
   test_one_half ();
-  
-#if 0
-  /* this one currently fails due to 
-   * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=165368 
-   */
   test_byte_order ();
-#endif
 
   return 0;
 }