diff options
author | Alberto Fanjul <albertofanjul@gmail.com> | 2020-05-20 16:45:05 +0200 |
---|---|---|
committer | Alberto Fanjul <albertofanjul@gmail.com> | 2020-05-20 19:48:19 +0200 |
commit | ec7a27242357c5621ffc1c703394169745777644 (patch) | |
tree | 8cf35d0471bf931703dead3b6ff6d05c68d5a333 | |
parent | b73f2016fb649bf29359f1c0032d6b3f32fedb38 (diff) | |
download | glade-ec7a27242357c5621ffc1c703394169745777644.tar.gz |
Ignore locale when saving numeric values
-rw-r--r-- | gladeui/glade-property-def.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/gladeui/glade-property-def.c b/gladeui/glade-property-def.c index 16ff9fb3..0d49f598 100644 --- a/gladeui/glade-property-def.c +++ b/gladeui/glade-property-def.c @@ -452,6 +452,21 @@ glade_property_def_make_string_from_objects (GladePropertyDef * return string; } +static locale_t +get_C_locale (void) +{ + static gsize initialized = FALSE; + static locale_t C_locale = NULL; + + if (g_once_init_enter (&initialized)) + { + C_locale = newlocale (LC_ALL_MASK, "C", NULL); + g_once_init_leave (&initialized, TRUE); + } + + return C_locale; +} + static gchar * glade_dtostr (double number, gdouble epsilon) { @@ -461,8 +476,10 @@ glade_dtostr (double number, gdouble epsilon) for (i = 0; i <= 20; i++) { double rounded; - + locale_t old_locale; + old_locale = uselocale (get_C_locale ()); snprintf (str, G_ASCII_DTOSTR_BUF_SIZE, "%.*f", i, number); + uselocale (old_locale); rounded = g_ascii_strtod (str, NULL); if (ABS (rounded - number) <= epsilon) |