From: Bruno Haible Date: Wed, 9 Jan 2002 20:43:23 +0000 (+0000) Subject: Use xsetenv before setlocale, because on non-glibc systems the libintl X-Git-Tag: v0.11~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=671659faef4bb8b4085d1bf1f58585e9555e5808;p=thirdparty%2Fgettext.git Use xsetenv before setlocale, because on non-glibc systems the libintl looks at the environment variables, not at the locale. --- diff --git a/tests/ChangeLog b/tests/ChangeLog index 1e92aa4f4..1ae0056b5 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2002-01-09 Bruno Haible + + * lang-c: Use xsetenv before setlocale. + * lang-c++: Likewise. + * lang-objc: Likewise. + * plural-1-prg.c: Likewise. + * Makefile.am (cake_LDADD): New variable. + 2002-01-08 Bruno Haible * msgattrib-*: Terminate the test immediately if the msg* program diff --git a/tests/Makefile.am b/tests/Makefile.am index 234bbaed9..3f9457f44 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -105,3 +105,4 @@ tstgettext_LDADD = ../lib/libgettextlib.la $(LDADD) tstngettext_SOURCES = tstngettext.c setlocale.c tstngettext_LDADD = ../lib/libgettextlib.la $(LDADD) cake_SOURCES = plural-1-prg.c setlocale.c +cake_LDADD = ../lib/libgettextlib.la $(LDADD) diff --git a/tests/lang-c b/tests/lang-c index 5196e9604..6c17636e5 100755 --- a/tests/lang-c +++ b/tests/lang-c @@ -13,6 +13,7 @@ cat <<\EOF > prog.c #include #include #include +#include "xsetenv.h" #define _(string) gettext (string) int main (argc, argv) @@ -21,7 +22,8 @@ int main (argc, argv) { int n = atoi (argv[2]); - if (setlocale (LC_ALL, argv[1]) == NULL) + xsetenv ("LC_ALL", argv[1], 1); + if (setlocale (LC_ALL, "") == NULL) { fprintf (stderr, "Couldn't set locale.\n"); exit (77); @@ -47,7 +49,7 @@ EOF top_builddir=.. tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}" -${LIBTOOL} --quiet --mode=link ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.c -I../intl ${INTLLIBS} \ +${LIBTOOL} --quiet --mode=link ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.c -I$top_srcdir/lib ../lib/libgettextlib.la -I../intl ${INTLLIBS} \ || exit 1 tmpfiles="$tmpfiles prog.pot" diff --git a/tests/lang-c++ b/tests/lang-c++ index e74f00ebf..e05525cfc 100755 --- a/tests/lang-c++ +++ b/tests/lang-c++ @@ -19,13 +19,15 @@ cat <<\EOF > prog.cc #include #include #include +#include "xsetenv.h" #define _(string) gettext (string) int main (int argc, char *argv[]) { int n = atoi (argv[2]); - if (setlocale (LC_ALL, argv[1]) == NULL) + xsetenv ("LC_ALL", argv[1], 1); + if (setlocale (LC_ALL, "") == NULL) { cerr << "Couldn't set locale." << endl; exit (77); @@ -48,7 +50,7 @@ EOF top_builddir=.. tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}" -${LIBTOOL} --quiet --mode=link ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.cc -I../intl ${INTLLIBS} \ +${LIBTOOL} --quiet --mode=link ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.cc -I$top_srcdir/lib ../lib/libgettextlib.la -I../intl ${INTLLIBS} \ || exit 1 tmpfiles="$tmpfiles prog.pot" diff --git a/tests/lang-objc b/tests/lang-objc index 3e5d296d3..1dc3e0534 100755 --- a/tests/lang-objc +++ b/tests/lang-objc @@ -27,6 +27,7 @@ cat <<\EOF > prog.m #include #include #include +#include "xsetenv.h" #define _(string) gettext (string) int main (argc, argv) @@ -35,7 +36,8 @@ int main (argc, argv) { int n = atoi (argv[2]); - if (setlocale (LC_ALL, argv[1]) == NULL) + xsetenv ("LC_ALL", argv[1], 1); + if (setlocale (LC_ALL, "") == NULL) { fprintf (stderr, "Couldn't set locale.\n"); exit (77); @@ -61,7 +63,7 @@ EOF top_builddir=.. tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}" -${LIBTOOL} --quiet --mode=link ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.m -I../intl ${INTLLIBS} \ +${LIBTOOL} --quiet --mode=link ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.m -I$top_srcdir/lib ../lib/libgettextlib.la -I../intl ${INTLLIBS} \ || exit 1 tmpfiles="$tmpfiles prog.pot" diff --git a/tests/plural-1-prg.c b/tests/plural-1-prg.c index 9642c1767..fa5d0a250 100644 --- a/tests/plural-1-prg.c +++ b/tests/plural-1-prg.c @@ -7,6 +7,7 @@ #include #include #include +#include "xsetenv.h" /* Make sure we use the included libintl, not the system's one. */ #define textdomain textdomain__ @@ -21,7 +22,8 @@ int main (argc, argv) { int n = atoi (argv[2]); - if (setlocale (LC_ALL, argv[1]) == NULL) + xsetenv ("LC_ALL", argv[1], 1); + if (setlocale (LC_ALL, "") == NULL) return 1; textdomain ("cake");