summaryrefslogtreecommitdiff
path: root/gettext-tools/tests/gettext-7-prg.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-12-26 11:56:47 +0100
committerBruno Haible <bruno@clisp.org>2009-12-26 14:44:01 +0100
commitc354e8ba4f7ec6bf827a2bd2eca229fa5bcdbac7 (patch)
treeb4349c67e94a18ed82ca0a68a38b66d297dfff76 /gettext-tools/tests/gettext-7-prg.c
parent0349960bcfe436f2e851dd35833e59f16159d4ca (diff)
downloadgettext-c354e8ba4f7ec6bf827a2bd2eca229fa5bcdbac7.tar.gz
Respect the thread-specific locale on MacOS X.
Diffstat (limited to 'gettext-tools/tests/gettext-7-prg.c')
-rw-r--r--gettext-tools/tests/gettext-7-prg.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/gettext-tools/tests/gettext-7-prg.c b/gettext-tools/tests/gettext-7-prg.c
index 9ea9fc806..a8e69e77e 100644
--- a/gettext-tools/tests/gettext-7-prg.c
+++ b/gettext-tools/tests/gettext-7-prg.c
@@ -1,5 +1,5 @@
/* Test program, used by the gettext-7 test.
- Copyright (C) 2005-2007 Free Software Foundation, Inc.
+ Copyright (C) 2005-2007, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <string.h>
-#if USE_POSIX_THREADS && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))
+#if USE_POSIX_THREADS && (__GLIBC__ >= 2 || (defined __APPLE__ && defined __MACH__)) && HAVE_USELOCALE
#include <pthread.h>
@@ -33,6 +33,18 @@
#undef _LIBINTL_H
#include "libgnuintl.h"
+/* Name of German locale in ISO-8859-1 or ISO-8859-15 encoding. */
+#if __GLIBC__ >= 2
+# define LOCALE_DE_ISO8859 "de_DE.ISO-8859-1"
+#elif defined __APPLE__ && defined __MACH__ /* MacOS X */
+# define LOCALE_DE_ISO8859 "de_DE.ISO8859-1"
+#else
+# define LOCALE_DE_ISO8859 "de_DE"
+#endif
+
+/* Name of German locale in UTF-8 encoding. */
+#define LOCALE_DE_UTF8 "de_DE.UTF-8"
+
/* Set to 1 if the program is not behaving correctly. */
int result;
@@ -72,7 +84,7 @@ thread1_execution (void *arg)
char *s;
waitfor (1);
- uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL));
+ uselocale (newlocale (LC_ALL_MASK, LOCALE_DE_ISO8859, NULL));
setto (2);
/* Here we expect output in ISO-8859-1. */
@@ -106,7 +118,7 @@ thread2_execution (void *arg)
char *s;
waitfor (2);
- uselocale (newlocale (LC_ALL_MASK, "de_DE.UTF-8", NULL));
+ uselocale (newlocale (LC_ALL_MASK, LOCALE_DE_UTF8, NULL));
setto (1);
/* Here we expect output in UTF-8. */
@@ -134,12 +146,36 @@ thread2_execution (void *arg)
return NULL;
}
+static void
+check_locale_exists (const char *name)
+{
+ if (newlocale (LC_ALL_MASK, name, NULL) == NULL)
+ {
+ printf ("%s\n", name);
+ exit (1);
+ }
+}
+
int
-main (void)
+main (int argc, char *argv[])
{
+ int arg;
pthread_t thread1;
pthread_t thread2;
+ arg = (argc > 1 ? atoi (argv[1]) : 0);
+ switch (arg)
+ {
+ case 1:
+ /* Check for the existence of the first locale. */
+ check_locale_exists (LOCALE_DE_ISO8859);
+ /* Check for the existence of the second locale. */
+ check_locale_exists (LOCALE_DE_UTF8);
+ return 0;
+ default:
+ break;
+ }
+
unsetenv ("LANGUAGE");
unsetenv ("OUTPUT_CHARSET");
textdomain ("tstthread");