]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
localename: Port to MacOS X 10.6.
authorBruno Haible <bruno@clisp.org>
Sun, 9 May 2010 02:25:39 +0000 (04:25 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 May 2010 02:27:13 +0000 (04:27 +0200)
gettext-runtime/intl/ChangeLog
gettext-runtime/intl/localename.c

index 2a5df98c036a17bb022063bef61b0950cee78dfe..f204d787cb4ab13496372b79d33b19162901520a 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-03  Bruno Haible  <bruno@clisp.org>
+
+       localename: Port to MacOS X 10.6.
+       * localename.c (gl_locale_name_thread_unsafe): On MacOS X, try the
+       memory layout of the locales in MacOS X 10.6 as well.
+       Reported by Panu Kekäläinen <panu@kekalainen.eu>.
+
 2010-05-08  Bruno Haible  <bruno@clisp.org>
 
        * config.charset: Update comments for Cygwin 1.7.
index 5c4cae1ad36def441c1a3f019388b0d1bb20949f..89a9692bbdbfef58d59b25c994f4ac30c4ff6630 100644 (file)
@@ -2625,12 +2625,24 @@ gl_locale_name_thread_unsafe (int category, const char *categoryname)
            locale names of length > 31, we can assume that it is NUL terminated
            in this buffer. But we need to make a copy of the locale name, of
            indefinite extent.  */
-        struct _xlocale
+        struct _xlocale_part1_v0 /* used in MacOS X 10.5 */
           {
             int32_t __refcount;
             void (*__free_extra)(void *);
             __darwin_mbstate_t __mbs[10];
             int64_t __magic;
+          };
+        struct _xlocale_part1_v1 /* used in MacOS X >= 10.6.0 */
+          {
+            int32_t __refcount;
+            void (*__free_extra)(void *);
+            __darwin_mbstate_t __mbs[10];
+            /*pthread_lock_t*/ int __lock;
+            int64_t __magic;
+          };
+        struct _xlocale_part2
+          {
+            int64_t __magic;
             unsigned char __collate_load_error;
             unsigned char __collate_substitute_nontrivial;
             unsigned char _messages_using_locale;
@@ -2689,7 +2701,23 @@ gl_locale_name_thread_unsafe (int category, const char *categoryname)
             char *_time_locale_buf;
             /* more */
           };
-        struct _xlocale *tlp = (struct _xlocale *) thread_locale;
+        struct _xlocale_part2 *tlp;
+        if (((struct _xlocale_part1_v0 *) thread_locale)->__magic
+            == 0x786C6F63616C6530LL)
+          /* MacOS X 10.5 */
+          tlp =
+            (struct _xlocale_part2 *)
+            &((struct _xlocale_part1_v0 *) thread_locale)->__magic;
+        else if (((struct _xlocale_part1_v1 *) thread_locale)->__magic
+                 == 0x786C6F63616C6530LL)
+          /* MacOS X >= 10.6.0 */
+          tlp =
+            (struct _xlocale_part2 *)
+            &((struct _xlocale_part1_v1 *) thread_locale)->__magic;
+        else
+          /* Unsupported version of MacOS X: The internals of 'struct _xlocale'
+             have changed again.  */
+          return "";
         switch (category)
           {
           case LC_CTYPE: