Commit ceb35b23 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Break _g_locale_charset() into two pieces - a fast "raw" piece, and a slow

Sat Dec 14 20:11:41 2002  Owen Taylor  <otaylor@redhat.com>

        * glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
        glib/gutf8.c: Break _g_locale_charset() into two pieces
        - a fast "raw" piece, and a slow "unalias pieces".
        Always call the "raw" piece, and call the unalias bit
        if it changes. Use a per-thread cache. (#79529)
parent c95ce4b3
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
Sat Dec 14 20:11:41 2002 Owen Taylor <otaylor@redhat.com>
* glib/libcharset/{localcharset.[ch] libcharset-glib.patch}
glib/gutf8.c: Break _g_locale_charset() into two pieces
- a fast "raw" piece, and a slow "unalias pieces".
Always call the "raw" piece, and call the unalias bit
if it changes. Use a per-thread cache. (#79529)
2002-12-15 Matthias Clasen <maclas@gmx.de>
* configure.in: Set TRIO_LIBS when building with trio.
......
......@@ -409,7 +409,8 @@ _g_charset_get_aliases (const char *canonical_name)
}
static gboolean
g_utf8_get_charset_internal (const char **a)
g_utf8_get_charset_internal (const char *raw_data,
const char **a)
{
const char *charset = getenv("CHARSET");
......@@ -428,7 +429,7 @@ g_utf8_get_charset_internal (const char **a)
* barrier, so we lock for it
*/
G_LOCK (aliases);
charset = _g_locale_charset ();
charset = _g_locale_charset_unalias (raw_data);
G_UNLOCK (aliases);
if (charset && *charset)
......@@ -447,8 +448,22 @@ g_utf8_get_charset_internal (const char **a)
return FALSE;
}
static int utf8_locale_cache = -1;
static const char *utf8_charset_cache = NULL;
typedef struct _GCharsetCache GCharsetCache;
struct _GCharsetCache {
gboolean is_utf8;
gchar *raw;
gchar *charset;
};
static void
charset_cache_free (gpointer data)
{
GCharsetCache *cache = data;
g_free (cache->raw);
g_free (cache->charset);
g_free (cache);
}
/**
* g_get_charset:
......@@ -471,16 +486,33 @@ static const char *utf8_charset_cache = NULL;
gboolean
g_get_charset (G_CONST_RETURN char **charset)
{
if (utf8_locale_cache != -1)
static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT;
GCharsetCache *cache = g_static_private_get (&cache_private);
const gchar *raw;
if (!cache)
{
if (charset)
*charset = utf8_charset_cache;
return utf8_locale_cache;
cache = g_new0 (GCharsetCache, 1);
g_static_private_set (&cache_private, cache, charset_cache_free);
}
utf8_locale_cache = g_utf8_get_charset_internal (&utf8_charset_cache);
if (charset)
*charset = utf8_charset_cache;
return utf8_locale_cache;
raw = _g_locale_charset_raw ();
if (!(cache->raw && strcmp (cache->raw, raw) == 0))
{
const gchar *new_charset;
g_free (cache->raw);
g_free (cache->charset);
cache->raw = g_strdup (raw);
cache->is_utf8 = g_utf8_get_charset_internal (raw, &new_charset);
cache->charset = g_strdup (new_charset);
}
if (charset)
*charset = cache->charset;
return cache->is_utf8;
}
/* unicode_strchr */
......
# Patch against libcharset version 1.1
--- /home/otaylor/ftp/libiconv-1.7.0.1/libcharset/lib/localcharset.c Wed Aug 8 08:52:28 2001
+++ localcharset.c Wed Sep 26 22:47:38 2001
@@ -83,8 +83,8 @@
diff -ur libcharset/localcharset.c /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/localcharset.c
--- libcharset/localcharset.c Sat Dec 14 20:04:44 2002
+++ /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/localcharset.c Sat Dec 14 20:09:45 2002
@@ -102,8 +102,8 @@
static const char * volatile charset_aliases;
/* Return a pointer to the contents of the charset.alias file. */
......@@ -12,16 +12,39 @@
{
const char *cp;
@@ -205,7 +205,7 @@
STATIC
#endif
@@ -235,14 +235,10 @@
If the canonical name cannot be determined, the result is a non-canonical
name. */
-#ifdef STATIC
-STATIC
-#endif
const char *
-locale_charset ()
+_g_locale_charset ()
+_g_locale_charset_raw ()
{
const char *codeset;
const char *aliases;
@@ -262,7 +262,7 @@
- const char *aliases;
#if !(defined WIN32 || defined OS2)
@@ -344,12 +340,23 @@
#endif
+ return codeset;
+}
+
+#ifdef STATIC
+STATIC
+#endif
+const char *
+_g_locale_charset_unalias (const char *codeset)
+{
+ const char *aliases;
+
if (codeset == NULL)
/* The canonical name cannot be determined. */
codeset = "";
/* Resolve alias. */
......@@ -30,8 +53,9 @@
*aliases != '\0';
aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
if (strcmp (codeset, aliases) == 0
--- /home/otaylor/ftp/libiconv-1.7.0.1/libcharset/m4/glibc21.m4 Sat Jun 17 14:31:21 2000
+++ glibc21.m4 Fri Sep 28 12:12:39 2001
diff -ur libcharset/glibc21.m4 /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/glibc21.m4
--- libcharset/glibc21.m4 Sat Dec 14 20:04:44 2002
+++ /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/glibc21.m4 Fri Sep 28 19:44:46 2001
@@ -3,7 +3,7 @@
# Test for the GNU C Library, version 2.1 or newer.
# From Bruno Haible.
......@@ -41,8 +65,9 @@
[
AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
ac_cv_gnu_library_2_1,
--- /home/otaylor/ftp/libiconv-1.7.0.1/libcharset/m4/codeset.m4 Mon Apr 3 04:06:24 2000
+++ codeset.m4 Fri Sep 28 12:12:44 2001
diff -ur libcharset/codeset.m4 /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/codeset.m4
--- libcharset/codeset.m4 Sat Dec 14 20:04:44 2002
+++ /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/codeset.m4 Fri Sep 28 19:44:46 2001
@@ -2,7 +2,7 @@
dnl From Bruno Haible.
......@@ -52,15 +77,17 @@
[
AC_CHECK_HEADERS(langinfo.h)
AC_CHECK_FUNCS(nl_langinfo)
--- /home/otaylor/ftp/libiconv-1.7.0.1/libcharset/include/libcharset.h.in Tue Mar 27 08:34:42 2001
+++ libcharset.h Wed Sep 26 21:55:40 2001
@@ -30,8 +30,8 @@
diff -ur libcharset/libcharset.h /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/libcharset.h
--- libcharset/libcharset.h Sat Dec 14 20:04:44 2002
+++ /home/otaylor/cvs/gnome2/glib-head/glib/libcharset/libcharset.h Sat Dec 14 19:03:11 2002
@@ -30,8 +30,9 @@
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
-extern const char * locale_charset (void);
-
+extern const char * _g_locale_charset (void);
+extern const char * _g_locale_charset_raw (void);
+extern const char * _g_locale_charset_unalias (const char *codeset);
+extern const char * _g_locale_get_charset_aliases (void);
#ifdef __cplusplus
......
......@@ -30,7 +30,8 @@ extern "C" {
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
extern const char * _g_locale_charset (void);
extern const char * _g_locale_charset_raw (void);
extern const char * _g_locale_charset_unalias (const char *codeset);
extern const char * _g_locale_get_charset_aliases (void);
#ifdef __cplusplus
......
......@@ -235,14 +235,10 @@ _g_locale_get_charset_aliases ()
If the canonical name cannot be determined, the result is a non-canonical
name. */
#ifdef STATIC
STATIC
#endif
const char *
_g_locale_charset ()
_g_locale_charset_raw ()
{
const char *codeset;
const char *aliases;
#if !(defined WIN32 || defined OS2)
......@@ -344,6 +340,17 @@ _g_locale_charset ()
#endif
return codeset;
}
#ifdef STATIC
STATIC
#endif
const char *
_g_locale_charset_unalias (const char *codeset)
{
const char *aliases;
if (codeset == NULL)
/* The canonical name cannot be determined. */
codeset = "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment