diff src/intl.c @ 2946:4a9a804b31cb

[xemacs-hg @ 2005-09-24 16:31:37 by olivierg] 2005-09-17 Olivier Galibert <galibert@xemacs.org> * intl.c (Fset_current_locale): setlocale return string is valid only until the next setlocale call.
author olivierg
date Sat, 24 Sep 2005 16:31:39 +0000
parents 2b6fa2618f76
children 98af8a976fc3
line wrap: on
line diff
--- a/src/intl.c	Fri Sep 23 21:51:45 2005 +0000
+++ b/src/intl.c	Sat Sep 24 16:31:39 2005 +0000
@@ -70,26 +70,31 @@
        (locale))
 {
   Extbyte *loc;
+  Lisp_Object str;
 
   CHECK_STRING (locale);
   /* RedHat 6.2 contains a locale called "Francais" with the C-cedilla
      encoded in ISO2022! */
   LISP_STRING_TO_EXTERNAL (locale, loc, Qctext);
   loc = setlocale (LC_ALL, loc);
-  setlocale (LC_NUMERIC, "C");
   if (!loc)
     return Qnil;
+  loc = xstrdup (loc);
+  setlocale (LC_NUMERIC, "C");
 #ifdef HAVE_X_WINDOWS
   if (!init_x_locale (locale))
     {
       /* Locale not supported under X.  Put it back. */
       setlocale (LC_ALL, loc);
       setlocale (LC_NUMERIC, "C");
+      free (loc);
       return Qnil;
     }
 #endif
 
-  return build_ext_string (loc, Qctext);
+  str = build_ext_string (loc, Qctext);
+  xfree (loc, Extbyte *);
+  return str;
 }
 
 #if 0