* use default configure options to find threadsafe locale
authorWilfried Göesgens <willi@citadel.org>
Sun, 24 Feb 2008 22:40:03 +0000 (22:40 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 24 Feb 2008 22:40:03 +0000 (22:40 +0000)
* if we don't have uselocale, opt out all functions / structs related to it.
* if LDFLAGS have:  -lgettextlib -lgettextpo -lgettextsrc -liconv -lintl this detection seems to work

webcit/configure.ac
webcit/fmt_date.c
webcit/gettext.c
webcit/webcit.h

index f416227c66c238353b861e236fc94e66d0d18561..548f68ce76888219cfdfc0b5cad215a9b88e63c4 100644 (file)
@@ -352,30 +352,30 @@ AC_ARG_ENABLE(nls,
        [  --disable-nls           do not use Native Language Support],
        ok_nls=no, ok_nls=yes)
 
-if test "$ok_nls" != "no"; then
-       AC_MSG_RESULT(Checking for per-thread NLS support...)
-       AC_TRY_RUN([
-                #define _GNU_SOURCE
-                #include <libintl.h>
-                #include <locale.h>
-                #include <time.h>
-                main() {
-                        char *foo = NULL;
-                        char baz[32];
-                       struct tm *tm;
-                        uselocale(LC_GLOBAL_LOCALE);
-                        foo = gettext("bar");
-                       if (0) {
-                               strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
-                       }
-                        exit(0);
-               }
-       ],
-               ok_uselocale=yes,
-               ok_uselocale=no
-       )
-       ok_nls=$ok_uselocale
-fi
+dnl if test "$ok_nls" != "no"; then
+dnl    AC_MSG_RESULT(Checking for per-thread NLS support...)
+dnl    AC_TRY_RUN([
+dnl                 #define _GNU_SOURCE
+dnl                 #include <libintl.h>
+dnl                 #include <locale.h>
+dnl                 #include <time.h>
+dnl                 main() {
+dnl                         char *foo = NULL;
+dnl                         char baz[32];
+dnl                    struct tm *tm;
+dnl                         uselocale(LC_GLOBAL_LOCALE);
+dnl                         foo = gettext("bar");
+dnl                    if (0) {
+dnl                            strftime_l(baz, sizeof baz, "%c", tm, LC_GLOBAL_LOCALE);
+dnl                    }
+dnl                         exit(0);
+dnl            }
+dnl    ],
+dnl            ok_uselocale=yes,
+dnl            ok_uselocale=no
+dnl    )
+dnl    ok_nls=$ok_uselocale
+dnl fi
 
 if test "$ok_nls" != "no"; then
        AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
index 13a4eb9286f6c012a0b0a433f3120926b0da93ff..26f3cc0fe6d9896f7c7fd452140e98603d85140d 100644 (file)
@@ -21,7 +21,8 @@ typedef unsigned char byte;
  */
 size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
 {
-#ifdef ENABLE_NLS
+
+#ifdef HAVE_USELOCALE
        if (wc_locales[WC->selected_language] == NULL) {
                return strftime(s, max, format, tm);
        }
index 37ef96545f418cc51afd6586be8f63aa2476f826..9c248454026eeb2f5568e65cd5f01e63190d21ce 100644 (file)
@@ -27,7 +27,9 @@ char *AvailLang[NUM_LANGS] = {
        "nl_NL"
 };
 
+#ifdef HAVE_USELOCALE
 locale_t wc_locales[NUM_LANGS]; /**< here we keep the parsed stuff */
+#endif
 
 /** Keep information about one locale */
 typedef struct _lang_pref{
@@ -259,11 +261,14 @@ void preset_locale(void)
  */
 void initialize_locales(void) {
        int i;
-       locale_t Empty_Locale;
        char buf[32];
 
+#ifdef HAVE_USELOCALE
+       locale_t Empty_Locale;
+
        /* create default locale */
        Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
+#endif
 
        for (i = 0; i < NUM_LANGS; ++i) {
                if (i == 0) {
@@ -272,6 +277,7 @@ void initialize_locales(void) {
                else {
                        sprintf(buf, "%s.UTF8", AvailLang[i]);
                }
+#ifdef HAVE_USELOCALE
                wc_locales[i] = newlocale(
                        (LC_MESSAGES_MASK|LC_TIME_MASK),
                        buf,
@@ -286,6 +292,7 @@ void initialize_locales(void) {
                else {
                        lprintf(3, "Configured available locale: %s\n", buf);
                }
+#endif
        }
 }
 
index ab0f7669635642f2a8d82e00ecf42c7ee0927e42..d47d6a830f572e14be365b743a78f93ad7fc25f2 100644 (file)
@@ -51,7 +51,9 @@
 #ifdef ENABLE_NLS
 #include <libintl.h>
 #include <locale.h>
+#ifdef HAVE_USELOCALE
 extern locale_t wc_locales[];
+#endif
 #define _(string)      gettext(string)
 #else
 #define _(string)      (string)