From e0a56a2d3c2cb55a6523813ab80d3bf21536a10d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 24 Feb 2008 22:40:03 +0000 Subject: [PATCH] * use default configure options to find threadsafe locale * 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 | 48 ++++++++++++++++++++++----------------------- webcit/fmt_date.c | 3 ++- webcit/gettext.c | 9 ++++++++- webcit/webcit.h | 2 ++ 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/webcit/configure.ac b/webcit/configure.ac index f416227c6..548f68ce7 100644 --- a/webcit/configure.ac +++ b/webcit/configure.ac @@ -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 - #include - #include - 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 +dnl #include +dnl #include +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) diff --git a/webcit/fmt_date.c b/webcit/fmt_date.c index 13a4eb928..26f3cc0fe 100644 --- a/webcit/fmt_date.c +++ b/webcit/fmt_date.c @@ -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); } diff --git a/webcit/gettext.c b/webcit/gettext.c index 37ef96545..9c2484540 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -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 } } diff --git a/webcit/webcit.h b/webcit/webcit.h index ab0f76696..d47d6a830 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -51,7 +51,9 @@ #ifdef ENABLE_NLS #include #include +#ifdef HAVE_USELOCALE extern locale_t wc_locales[]; +#endif #define _(string) gettext(string) #else #define _(string) (string) -- 2.30.2