This was in my sources for some time, but I somehow failed to send it.

The problem is that nl_langinfo can return pointers to static buffers
that are overwritten on subsequent calls.  So we need to usher the
value away before the next call.

--- libguile/i18n.c~0   2014-08-08 17:05:57.262034100 +0300
+++ libguile/i18n.c     2014-08-09 13:04:19.901125000 +0300
@@ -1522,6 +1522,8 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinf
       else
        {
          c_result = nl_langinfo (c_item);
+         if (c_result != NULL)
+           c_result = strdup (c_result);
           codeset = nl_langinfo (CODESET);
 
          restore_locale_settings (&lsec_prev_locale);
@@ -1532,12 +1534,11 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinf
   else
     {
       c_result = nl_langinfo (c_item);
+      if (c_result != NULL)
+       c_result = strdup (c_result);
       codeset = nl_langinfo (CODESET);
     }
 
-  if (c_result != NULL)
-    c_result = strdup (c_result);
-
   unlock_locale_mutex ();
 
   if (c_result == NULL)



Reply via email to