From f3ac581713f7297b0bf33c77c47e9bf32961775f Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 18 Oct 2011 00:15:37 +0800 Subject: [PATCH] Move _glib_get_locale_dir to ggettext.c -Move _glib_get_locale_dir to ggettext.c, as Matthias suggested -Made up for the headers that needed to be included in ggettext.c to avoid C4013 (implicit declaration of ...) errors/warnings --- glib/ggettext.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ glib/gutils.c | 50 ------------------------------------------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/glib/ggettext.c b/glib/ggettext.c index 58f74d21f..d7054fcbe 100644 --- a/glib/ggettext.c +++ b/glib/ggettext.c @@ -30,11 +30,67 @@ #include "galloca.h" #include "gthread.h" +#include "gmem.h" +#ifdef G_OS_WIN32 +#include "gwin32.h" +#include "gfileutils.h" +#include "gstrfuncs.h" +#include "glib-init.h" +#endif #include #include #include +#ifdef G_OS_WIN32 + +/** + * _glib_get_locale_dir: + * + * Return the path to the share\locale or lib\locale subfolder of the + * GLib installation folder. The path is in the system codepage. We + * have to use system codepage as bindtextdomain() doesn't have a + * UTF-8 interface. + */ +gchar * +_glib_get_locale_dir (void) +{ + gchar *install_dir = NULL, *locale_dir; + gchar *retval = NULL; + + if (glib_dll != NULL) + install_dir = g_win32_get_package_installation_directory_of_module (glib_dll); + + if (install_dir) + { + /* + * Append "/share/locale" or "/lib/locale" depending on whether + * autoconfigury detected GNU gettext or not. + */ + const char *p = GLIB_LOCALE_DIR + strlen (GLIB_LOCALE_DIR); + while (*--p != '/') + ; + while (*--p != '/') + ; + + locale_dir = g_build_filename (install_dir, p, NULL); + + retval = g_win32_locale_filename_from_utf8 (locale_dir); + + g_free (install_dir); + g_free (locale_dir); + } + + if (retval) + return retval; + else + return g_strdup (""); +} + +#undef GLIB_LOCALE_DIR + +#endif /* G_OS_WIN32 */ + static void ensure_gettext_initialized (void) diff --git a/glib/gutils.c b/glib/gutils.c index 63fb5ce83..934452d2b 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -2330,56 +2330,6 @@ g_format_size_for_display (goffset size) } } -#ifdef G_OS_WIN32 - -/** - * _glib_get_locale_dir: - * - * Return the path to the share\locale or lib\locale subfolder of the - * GLib installation folder. The path is in the system codepage. We - * have to use system codepage as bindtextdomain() doesn't have a - * UTF-8 interface. - */ -gchar * -_glib_get_locale_dir (void) -{ - gchar *install_dir = NULL, *locale_dir; - gchar *retval = NULL; - - if (glib_dll != NULL) - install_dir = g_win32_get_package_installation_directory_of_module (glib_dll); - - if (install_dir) - { - /* - * Append "/share/locale" or "/lib/locale" depending on whether - * autoconfigury detected GNU gettext or not. - */ - const char *p = GLIB_LOCALE_DIR + strlen (GLIB_LOCALE_DIR); - while (*--p != '/') - ; - while (*--p != '/') - ; - - locale_dir = g_build_filename (install_dir, p, NULL); - - retval = g_win32_locale_filename_from_utf8 (locale_dir); - - g_free (install_dir); - g_free (locale_dir); - } - - if (retval) - return retval; - else - return g_strdup (""); -} - -#undef GLIB_LOCALE_DIR - -#endif /* G_OS_WIN32 */ - - #if defined (G_OS_WIN32) && !defined (_WIN64) /* Binary compatibility versions. Not for newly compiled code. */