[gvfs] common: use nl_langinfo constants conditionally



commit a77cdbac08ca1ff17aeba2323a610a61101387db
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Mar 20 16:44:44 2014 +0100

    common: use nl_langinfo constants conditionally
    
    The _NL_ADDRESS_LANG_TERM and _NL_ADDRESS_COUNTRY_AB3 aren't portable.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726707

 common/gvfsmountinfo.c |    6 +++++-
 configure.ac           |   10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/common/gvfsmountinfo.c b/common/gvfsmountinfo.c
index 054af57..d206b91 100644
--- a/common/gvfsmountinfo.c
+++ b/common/gvfsmountinfo.c
@@ -429,15 +429,19 @@ GIcon *g_vfs_mount_info_query_xdg_volume_info_finish (GFile          *directory,
 static const char *
 get_iso_639_3_for_locale (void)
 {
-  const char *lang;
+  const char *lang = NULL;
 
+#ifdef HAVE_NL_ADDRESS_LANG_TERM
   lang = nl_langinfo (_NL_ADDRESS_LANG_TERM);
   if (lang == NULL || *lang == '\0')
     {
+#ifdef HAVE_NL_ADDRESS_COUNTRY_AB3
       lang = nl_langinfo (_NL_ADDRESS_COUNTRY_AB3);
       if (lang == NULL || *lang == '\0')
+#endif
         return NULL;
     }
+#endif
 
   return lang;
 }
diff --git a/configure.ac b/configure.ac
index 63a5c11..dd45969 100644
--- a/configure.ac
+++ b/configure.ac
@@ -735,6 +735,16 @@ if test "x$enable_afp" != "xno"; then
 fi
 AM_CONDITIONAL(USE_AFP, test "x$enable_afp" != "xno")
 
+dnl ***************************************
+dnl *** Check for nl_langinfo constants ***
+dnl ***************************************
+AC_CHECK_DECL(_NL_ADDRESS_LANG_TERM,
+              AC_DEFINE(HAVE_NL_ADDRESS_LANG_TERM, 1, Define to 1 if _NL_ADDRESS_LANG_TERM is declared),,
+              [#include <langinfo.h>])
+AC_CHECK_DECL(_NL_ADDRESS_COUNTRY_AB3,
+              AC_DEFINE(HAVE_NL_ADDRESS_COUNTRY_AB3, 1, Define to 1 if _NL_ADDRESS_COUNTRY_AB3 is declared),,
+              [#include <langinfo.h>])
+
 dnl Install bash-completion file?
 AC_ARG_ENABLE([bash-completion],
              AS_HELP_STRING([--disable-bash-completion],


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