diff options
Diffstat (limited to 'gettext-tools/tests/gettext-7-prg.c')
-rw-r--r-- | gettext-tools/tests/gettext-7-prg.c | 46 |
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"); |