bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'duplocale'


From: Bruno Haible
Subject: Re: new module 'duplocale'
Date: Mon, 23 Nov 2009 11:07:34 +0100
User-agent: KMail/1.9.9

This code would not work all right on glibc 2.3.x systems, when
setlocale has been called with an argument different from "". This should
fix it.

2009-11-23  Bruno Haible  <address@hidden>

        duplocale: Add support for glibc 2.3.x.
        * lib/duplocale.c (rpl_duplocale): Add fallback code for glibc 2.3.x.

*** lib/duplocale.c.orig        2009-11-23 11:04:25.000000000 +0100
--- lib/duplocale.c     2009-11-23 11:02:46.000000000 +0100
***************
*** 70,79 ****
          , { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK }
  #endif
        };
!       const char *base_name = nl_langinfo (_NL_LOCALE_NAME (LC_CTYPE));
!       locale_t base_copy = newlocale (LC_ALL_MASK, base_name, NULL);
        unsigned int i;
  
        if (base_copy == NULL)
        return NULL;
  
--- 70,85 ----
          , { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK }
  #endif
        };
!       const char *base_name;
!       locale_t base_copy;
        unsigned int i;
  
+       base_name = nl_langinfo (_NL_LOCALE_NAME (LC_CTYPE));
+       if (base_name[0] == '\0')
+       /* Fallback code for glibc < 2.4, which did not implement
+          nl_langinfo (_NL_LOCALE_NAME (category)).  */
+       base_name = setlocale (LC_CTYPE, NULL);
+       base_copy = newlocale (LC_ALL_MASK, base_name, NULL);
        if (base_copy == NULL)
        return NULL;
  
***************
*** 82,87 ****
--- 88,97 ----
          int category = categories[i].cat;
          int category_mask = categories[i].mask;
          const char *name = nl_langinfo (_NL_LOCALE_NAME (category));
+         if (name[0] == '\0')
+           /* Fallback code for glibc < 2.4, which did not implement
+              nl_langinfo (_NL_LOCALE_NAME (category)).  */
+           name = setlocale (category, NULL);
          if (strcmp (name, base_name) != 0)
            {
              locale_t copy = newlocale (category_mask, name, base_copy);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]