]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add support for glibc's new NL_LOCALE_NAME macro.
authorBruno Haible <bruno@clisp.org>
Tue, 3 May 2005 10:37:26 +0000 (10:37 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:12:32 +0000 (12:12 +0200)
gettext-runtime/intl/dcigettext.c
gettext-runtime/m4/gettext.m4

index f5a8915b1706423739e8bf307d545cfad517147d..8cb5ec88daed239abe288abd2b9331512eac731e 100644 (file)
@@ -87,6 +87,10 @@ extern int errno;
 # include <sys/param.h>
 #endif
 
+#if !defined _LIBC && HAVE_NL_LOCALE_NAME
+# include <langinfo.h>
+#endif
+
 #include "gettextP.h"
 #include "plural-exp.h"
 #ifdef _LIBC
@@ -217,7 +221,7 @@ static void *mempcpy (void *dest, const void *src, size_t n);
 #endif
 
 /* Whether to support different locales in different threads.  */
-#if defined _LIBC || (HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS)
+#if defined _LIBC || HAVE_NL_LOCALE_NAME || (HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS)
 # define HAVE_PER_THREAD_LOCALE
 #endif
 
@@ -510,7 +514,11 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
 #  ifdef _LIBC
   localename = __current_locale_name (category);
 #  else
-#   if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS
+#   if HAVE_NL_LOCALE_NAME
+  /* NL_LOCALE_NAME is public glibc API introduced in glibc-2.4.  */
+  localename = nl_langinfo (NL_LOCALE_NAME (category));
+#   else
+#    if HAVE_STRUCT___LOCALE_STRUCT___NAMES && defined USE_IN_GETTEXT_TESTS
   /* The __names field is not public glibc API and must therefore not be used
      in code that is installed in public locations.  */
   {
@@ -520,6 +528,7 @@ DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
     else
       localename = "";
   }
+#    endif
 #   endif
 #  endif
   search->localename = localename;
index 624a807859252399c71507da4429e44c419f3203..c0caa41b4cca0ede6cbf8d193fdcd0c8962e500c 100644 (file)
@@ -1,4 +1,4 @@
-# gettext.m4 serial 37 (gettext-0.14.4)
+# gettext.m4 serial 38 (gettext-0.15)
 dnl Copyright (C) 1995-2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -444,6 +444,19 @@ __fsetlocking])
     gt_LC_MESSAGES
   fi
 
+  dnl glibc >= 2.4 has a NL_LOCALE_NAME macro when _GNU_SOUURCE is defined,
+  dnl and a _NL_LOCALE_NAME macro always.
+  AC_CACHE_CHECK([for NL_LOCALE_NAME macro], gt_cv_nl_locale_name,
+    [AC_TRY_LINK([#include <langinfo.h>],
+      [char* cs = nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES));],
+      gt_cv_nl_locale_name=yes,
+      gt_cv_nl_locale_name=no)
+    ])
+  if test $gt_cv_nl_locale_name = yes; then
+    AC_DEFINE(HAVE_NL_LOCALE_NAME, 1,
+      [Define if you have <langinfo.h> and it defines the NL_LOCALE_NAME macro if _GNU_SOUURCE is defined.])
+  fi
+
   if test -n "$INTL_MACOSX_LIBS"; then
     CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers"
   fi