[monkey-bubble: 111/753] setlocale returns a static buffer. Copy it to safety. Set the locale AFTER



commit 9f4798c54099b0d166d29b0310e70d1cfa4a08b3
Author: Jody Goldberg <jgoldberg home com>
Date:   Tue Jun 20 18:41:57 2000 +0000

    setlocale returns a static buffer. Copy it to safety. Set the locale AFTER
    
    
    2000-06-15  Jody Goldberg <jgoldberg home com>
    
    	* gnome-score.c (print_ascore) : setlocale returns a static buffer.
    	  Copy it to safety.  Set the locale AFTER storing the current
    	  setting.
    	(log_score) : Ditto.
    	(gnome_score_get_notable) : Ditto.
    
    	* gnome-config.c (_gnome_config_get_float_with_default): Ditto.
    	(_gnome_config_set_float) : Ditto.
    
    2000-06-15  Jody Goldberg <jgoldberg home com>
    
    	* gnome-calculator.c (set_result) : setlocale returns a static buffer.
    	  Copy it to safety.  Set the locale AFTER storing the current
    	  setting.
    	(add_digit) : Ditto.
    	(negate_val) : Ditto.

 libgnome/gnome-score.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/libgnome/gnome-score.c b/libgnome/gnome-score.c
index 23b941c..c6dce31 100644
--- a/libgnome/gnome-score.c
+++ b/libgnome/gnome-score.c
@@ -88,10 +88,12 @@ 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");
+   char *old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
+   setlocale (LC_NUMERIC, "C");
    fprintf (outfile, "%f %ld %s\n", ascore->score,
 	    (long int) ascore->scoretime, ascore->username);
    setlocale (LC_NUMERIC, old_locale);
+   g_free (old_locale);
 }
 
 static void
@@ -135,7 +137,8 @@ log_score (const gchar * progname, const gchar * level, gchar * username,
    if (infile)
      {
        /* make sure we read values from files in a consistent manner */
-       char *old_locale = setlocale (LC_NUMERIC, "C");
+       char *old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
+       setlocale (LC_NUMERIC, "C");
        while(fgets(buf, sizeof(buf), infile))
 	 {
 	     long ltime;
@@ -153,6 +156,7 @@ log_score (const gchar * progname, const gchar * level, gchar * username,
 	     scores = g_list_append (scores, (gpointer) anitem);
 	  }
         setlocale (LC_NUMERIC, old_locale);
+	g_free (old_locale);
 	fclose (infile);
      }
    
@@ -417,7 +421,8 @@ gnome_score_get_notable (gchar * gamename,
    
    if (infile)
      {
-        char *old_locale = setlocale (LC_NUMERIC, "C");
+        char *old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
+        setlocale (LC_NUMERIC, "C");
 
 	*names = g_malloc ((NSCORES + 1) * sizeof (gchar *));
 	*scores = g_malloc ((NSCORES + 1) * sizeof (gfloat));
@@ -441,6 +446,7 @@ gnome_score_get_notable (gchar * gamename,
 	(*scores)[retval] = 0.0;
 
         setlocale (LC_NUMERIC, old_locale);
+	g_free (old_locale);
 	fclose (infile);
      }
    else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]