mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Update the returned value after locale changes. (#160271, Christian
2004-12-07 Matthias Clasen <mclasen@redhat.com> * glib/gutils.c (g_get_language_names): Update the returned value after locale changes. (#160271, Christian Persch) (_g_utils_thread_init): Initialize the language name cache before going threaded. * glib/gthread.c (g_thread_init_glib): Call _g_utils_thread_init(). * glib/gthreadinit.h: Add _g_utils_thread_init().
This commit is contained in:
parent
9a62b4b291
commit
10632e416f
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_language_names): Update the returned
|
||||||
|
value after locale changes. (#160271, Christian Persch)
|
||||||
|
(_g_utils_thread_init): Initialize the language name cache
|
||||||
|
before going threaded.
|
||||||
|
|
||||||
|
* glib/gthread.c (g_thread_init_glib): Call _g_utils_thread_init().
|
||||||
|
|
||||||
|
* glib/gthreadinit.h: Add _g_utils_thread_init().
|
||||||
|
|
||||||
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_language_names): Update the returned
|
||||||
|
value after locale changes. (#160271, Christian Persch)
|
||||||
|
(_g_utils_thread_init): Initialize the language name cache
|
||||||
|
before going threaded.
|
||||||
|
|
||||||
|
* glib/gthread.c (g_thread_init_glib): Call _g_utils_thread_init().
|
||||||
|
|
||||||
|
* glib/gthreadinit.h: Add _g_utils_thread_init().
|
||||||
|
|
||||||
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_language_names): Update the returned
|
||||||
|
value after locale changes. (#160271, Christian Persch)
|
||||||
|
(_g_utils_thread_init): Initialize the language name cache
|
||||||
|
before going threaded.
|
||||||
|
|
||||||
|
* glib/gthread.c (g_thread_init_glib): Call _g_utils_thread_init().
|
||||||
|
|
||||||
|
* glib/gthreadinit.h: Add _g_utils_thread_init().
|
||||||
|
|
||||||
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_language_names): Update the returned
|
||||||
|
value after locale changes. (#160271, Christian Persch)
|
||||||
|
(_g_utils_thread_init): Initialize the language name cache
|
||||||
|
before going threaded.
|
||||||
|
|
||||||
|
* glib/gthread.c (g_thread_init_glib): Call _g_utils_thread_init().
|
||||||
|
|
||||||
|
* glib/gthreadinit.h: Add _g_utils_thread_init().
|
||||||
|
|
||||||
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-07 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_language_names): Update the returned
|
||||||
|
value after locale changes. (#160271, Christian Persch)
|
||||||
|
(_g_utils_thread_init): Initialize the language name cache
|
||||||
|
before going threaded.
|
||||||
|
|
||||||
|
* glib/gthread.c (g_thread_init_glib): Call _g_utils_thread_init().
|
||||||
|
|
||||||
|
* glib/gthreadinit.h: Add _g_utils_thread_init().
|
||||||
|
|
||||||
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
2004-12-06 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
* glib/giowin32.c (g_io_win32_finalize): Fix a write to freed
|
||||||
|
@ -152,6 +152,7 @@ g_thread_init_glib (void)
|
|||||||
_g_mem_thread_init ();
|
_g_mem_thread_init ();
|
||||||
_g_messages_thread_init ();
|
_g_messages_thread_init ();
|
||||||
_g_atomic_thread_init ();
|
_g_atomic_thread_init ();
|
||||||
|
_g_utils_thread_init ();
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
_g_win32_thread_init ();
|
_g_win32_thread_init ();
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,6 +33,7 @@ void _g_convert_thread_init (void) G_GNUC_INTERNAL;
|
|||||||
void _g_rand_thread_init (void) G_GNUC_INTERNAL;
|
void _g_rand_thread_init (void) G_GNUC_INTERNAL;
|
||||||
void _g_main_thread_init (void) G_GNUC_INTERNAL;
|
void _g_main_thread_init (void) G_GNUC_INTERNAL;
|
||||||
void _g_atomic_thread_init (void) G_GNUC_INTERNAL;
|
void _g_atomic_thread_init (void) G_GNUC_INTERNAL;
|
||||||
|
void _g_utils_thread_init (void) G_GNUC_INTERNAL;
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
void _g_win32_thread_init (void) G_GNUC_INTERNAL;
|
void _g_win32_thread_init (void) G_GNUC_INTERNAL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "galias.h"
|
#include "galias.h"
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
#include "gprintfint.h"
|
#include "gprintfint.h"
|
||||||
|
#include "gthreadinit.h"
|
||||||
|
|
||||||
#ifdef MAXPATHLEN
|
#ifdef MAXPATHLEN
|
||||||
#define G_PATH_LENGTH MAXPATHLEN
|
#define G_PATH_LENGTH MAXPATHLEN
|
||||||
@ -1919,7 +1920,21 @@ guess_category_value (const gchar *category_name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar **languages = NULL;
|
typedef struct _GLanguageNamesCache GLanguageNamesCache;
|
||||||
|
|
||||||
|
struct _GLanguageNamesCache {
|
||||||
|
gchar *languages;
|
||||||
|
gchar **language_names;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
language_names_cache_free (gpointer data)
|
||||||
|
{
|
||||||
|
GLanguageNamesCache *cache = data;
|
||||||
|
g_free (cache->languages);
|
||||||
|
g_strfreev (cache->language_names);
|
||||||
|
g_free (cache);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_get_language_names:
|
* g_get_language_names:
|
||||||
@ -1944,18 +1959,30 @@ static gchar **languages = NULL;
|
|||||||
G_CONST_RETURN gchar * G_CONST_RETURN *
|
G_CONST_RETURN gchar * G_CONST_RETURN *
|
||||||
g_get_language_names (void)
|
g_get_language_names (void)
|
||||||
{
|
{
|
||||||
G_LOCK (g_utils_global);
|
static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT;
|
||||||
|
GLanguageNamesCache *cache = g_static_private_get (&cache_private);
|
||||||
|
const gchar *value;
|
||||||
|
|
||||||
if (!languages)
|
if (!cache)
|
||||||
{
|
{
|
||||||
const gchar *value;
|
cache = g_new0 (GLanguageNamesCache, 1);
|
||||||
|
g_static_private_set (&cache_private, cache, language_names_cache_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = guess_category_value ("LC_MESSAGES");
|
||||||
|
if (!value)
|
||||||
|
value = "C";
|
||||||
|
|
||||||
|
if (!(cache->languages && strcmp (cache->languages, value) == 0))
|
||||||
|
{
|
||||||
|
gchar **languages;
|
||||||
gchar **alist, **a;
|
gchar **alist, **a;
|
||||||
GSList *list, *l;
|
GSList *list, *l;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
value = guess_category_value ("LC_MESSAGES");
|
g_free (cache->languages);
|
||||||
if (!value)
|
g_strfreev (cache->language_names);
|
||||||
value = "C";
|
cache->languages = g_strdup (value);
|
||||||
|
|
||||||
alist = g_strsplit (value, ":", 0);
|
alist = g_strsplit (value, ":", 0);
|
||||||
list = NULL;
|
list = NULL;
|
||||||
@ -1965,9 +1992,9 @@ g_get_language_names (void)
|
|||||||
list = g_slist_concat (list, _g_compute_locale_variants (b));
|
list = g_slist_concat (list, _g_compute_locale_variants (b));
|
||||||
}
|
}
|
||||||
g_strfreev (alist);
|
g_strfreev (alist);
|
||||||
list = g_slist_append (list, "C");
|
list = g_slist_append (list, g_strdup ("C"));
|
||||||
|
|
||||||
languages = g_new (gchar *, g_slist_length (list) + 1);
|
cache->language_names = languages = g_new (gchar *, g_slist_length (list) + 1);
|
||||||
for (l = list, i = 0; l; l = l->next, i++)
|
for (l = list, i = 0; l; l = l->next, i++)
|
||||||
languages[i] = l->data;
|
languages[i] = l->data;
|
||||||
languages[i] = NULL;
|
languages[i] = NULL;
|
||||||
@ -1975,9 +2002,7 @@ g_get_language_names (void)
|
|||||||
g_slist_free (list);
|
g_slist_free (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_UNLOCK (g_utils_global);
|
return (G_CONST_RETURN gchar * G_CONST_RETURN *) cache->language_names;
|
||||||
|
|
||||||
return (G_CONST_RETURN gchar * G_CONST_RETURN *) languages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
@ -2038,6 +2063,15 @@ g_get_codeset (void)
|
|||||||
return g_strdup (charset);
|
return g_strdup (charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is called from g_thread_init(). It's used to
|
||||||
|
* initialize some static data in a threadsafe way.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_g_utils_thread_init (void)
|
||||||
|
{
|
||||||
|
g_get_language_names ();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
|
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user