[glade/glade-3-36.msvc: 13/18] glade-property-def.c: Fix building on Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade/glade-3-36.msvc: 13/18] glade-property-def.c: Fix building on Windows
- Date: Mon, 8 Jun 2020 10:11:12 +0000 (UTC)
commit 72004302a1815c638b365e8b2b30d89f9275411a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jun 8 17:09:13 2020 +0800
glade-property-def.c: Fix building on Windows
uselocale() and newlocale() are locale.h functions that are only
available on *NIX.
gladeui/glade-property-def.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gladeui/glade-property-def.c b/gladeui/glade-property-def.c
index d33dd4ea..f18e5c66 100644
--- a/gladeui/glade-property-def.c
+++ b/gladeui/glade-property-def.c
@@ -453,15 +453,27 @@ glade_property_def_make_string_from_objects (GladePropertyDef *
return string;
}
-static locale_t
+#ifdef G_OS_WIN32
+# define LOCALE_TYPE char *
+# define uselocale(x) setlocale (LC_ALL, x)
+#else
+# define LOCALE_TYPE locale_t
+#endif
+
+static LOCALE_TYPE
get_C_locale (void)
{
static gsize initialized = FALSE;
- static locale_t C_locale = NULL;
+ static LOCALE_TYPE C_locale = NULL;
if (g_once_init_enter (&initialized))
{
- C_locale = newlocale (LC_ALL_MASK, "C", NULL);
+#ifdef G_OS_WIN32
+ _configthreadlocale (_ENABLE_PER_THREAD_LOCALE);
+ C_locale = "C";
+#else
+ C_locale = newlocale (LC_ALL, "C");
+#endif
g_once_init_leave (&initialized, TRUE);
}
@@ -477,7 +489,7 @@ glade_dtostr (double number, gdouble epsilon)
for (i = 0; i <= 20; i++)
{
double rounded;
- locale_t old_locale;
+ LOCALE_TYPE old_locale;
old_locale = uselocale (get_C_locale ());
snprintf (str, G_ASCII_DTOSTR_BUF_SIZE, "%.*f", i, number);
uselocale (old_locale);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]