[monkey-bubble: 107/753] setlocae for LC_NUMERIC to "C" and then back to original locale when
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 107/753] setlocae for LC_NUMERIC to "C" and then back to original locale when
- Date: Wed, 14 Jul 2010 22:04:40 +0000 (UTC)
commit 4987f94821f0c01736884e05f1a96c6cce94b69c
Author: George Lebl <jirka 5z com>
Date: Sat May 6 23:59:16 2000 +0000
setlocae for LC_NUMERIC to "C" and then back to original locale when
Sat May 06 16:46:13 2000 George Lebl <jirka 5z com>
* gnome-config.c (_gnome_config_get_float_with_default)
(_gnome_config_set_float): setlocae for LC_NUMERIC to "C" and
then back to original locale when reading and writing floats
so that we can read/write floats over different locales
* gnome-score.c (gnome_get_score_file_name) (log_score):
The same as above. Fixes bugs #10404, #10257
libgnome/gnome-score.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/libgnome/gnome-score.c b/libgnome/gnome-score.c
index 5014691..11fd974 100644
--- a/libgnome/gnome-score.c
+++ b/libgnome/gnome-score.c
@@ -37,6 +37,7 @@
#include <glib.h>
#include <pwd.h>
#include <ctype.h>
+#include <locale.h>
#ifdef HAVE_SYS_FSUID_H
#ifdef HAVE_SETFSGID
#include <sys/fsuid.h>
@@ -86,8 +87,11 @@ gnome_get_score_file_name (const gchar * progname, const gchar * level)
static void
print_ascore (struct ascore_t *ascore, FILE * outfile)
{
+ /* make sure we write values to files in a consistent manner */
+ char *old_locale = setlocale (LC_NUMERIC, "C");
fprintf (outfile, "%f %ld %s\n", ascore->score,
(long int) ascore->scoretime, ascore->username);
+ setlocale (LC_NUMERIC, old_locale);
}
static void
@@ -130,6 +134,8 @@ log_score (const gchar * progname, const gchar * level, gchar * username,
infile = fopen (game_score_file, "r");
if (infile)
{
+ /* make sure we read values from files in a consistent manner */
+ char *old_locale = setlocale (LC_NUMERIC, "C");
while(fgets(buf, sizeof(buf), infile))
{
long ltime;
@@ -146,6 +152,7 @@ log_score (const gchar * progname, const gchar * level, gchar * username,
anitem->scoretime = (time_t)ltime;
scores = g_list_append (scores, (gpointer) anitem);
}
+ setlocale (LC_NUMERIC, old_locale);
fclose (infile);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]