diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-08-08 19:50:38 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-08-08 19:50:38 +0000 |
commit | 717f3d4abbe99467f07b05462d7651b08e69dd20 (patch) | |
tree | 3b81ed49b4bd4e0f01fe98d9f3d996e49c8ccc2b | |
parent | 81b6a73938f881fb15f995a7837f0654e08941b0 (diff) |
Enable the endianness test.
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.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 14 | ||||
-rw-r--r-- | configure.in | 28 | ||||
-rw-r--r-- | glib/gconvert.c | 43 | ||||
-rw-r--r-- | tests/convert-test.c | 9 |
7 files changed, 128 insertions, 8 deletions
@@ -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. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d17cb9bb0..4b405fa19 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -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. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index d17cb9bb0..4b405fa19 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -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. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d17cb9bb0..4b405fa19 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -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. diff --git a/configure.in b/configure.in index 77086e11a..e79e87330 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/glib/gconvert.c b/glib/gconvert.c index 4504fd81b..bae23c480 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -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 diff --git a/tests/convert-test.c b/tests/convert-test.c index 2b7596fac..bc47456bc 100644 --- a/tests/convert-test.c +++ b/tests/convert-test.c @@ -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; } |