changeset 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 5b00db3049ec
children 1d3c4ed33763
files src/ChangeLog src/intl.c
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Sep 23 21:51:45 2005 +0000
+++ b/src/ChangeLog	Sat Sep 24 16:31:39 2005 +0000
@@ -1,3 +1,8 @@
+2005-09-17  Olivier Galibert  <galibert@xemacs.org>
+
+	* intl.c (Fset_current_locale): setlocale return string is valid
+	only until the next setlocale call.
+
 2005-09-12  Mike Alexander  <mta@arbortext.com>
 
 	* intl-win32.c (mswindows_current_locale): Define in non-MULE
--- 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