Mercurial > gnulib
annotate m4/locale-fr.m4 @ 40057:b06060465f09
maint: Run 'make update-copyright'
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 01 Jan 2019 00:25:11 +0100 |
parents | beb2ad957aca |
children |
rev | line source |
---|---|
19595
beb2ad957aca
Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
1 # locale-fr.m4 serial 19 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19595
diff
changeset
|
2 dnl Copyright (C) 2003, 2005-2019 Free Software Foundation, Inc. |
8132 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 dnl From Bruno Haible. | |
8 | |
9 dnl Determine the name of a french locale with traditional encoding. | |
10 AC_DEFUN([gt_LOCALE_FR], | |
11 [ | |
12 AC_REQUIRE([AC_CANONICAL_HOST]) | |
13 AC_REQUIRE([AM_LANGINFO_CODESET]) | |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
10962
diff
changeset
|
14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ |
11092
baa54e3c744f
Use non-UTF-8 locales on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ |
8132 | 16 changequote(,)dnl |
17 #include <locale.h> | |
18 #include <time.h> | |
19 #if HAVE_LANGINFO_CODESET | |
20 # include <langinfo.h> | |
21 #endif | |
9354
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
22 #include <stdlib.h> |
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
23 #include <string.h> |
8132 | 24 struct tm t; |
25 char buf[16]; | |
26 int main () { | |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
27 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
28 imitates locale dependent behaviour by looking at the environment |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
29 variables, and all locales use the UTF-8 encoding. */ |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
30 #if defined __BEOS__ || defined __HAIKU__ |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
31 return 1; |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
32 #else |
8132 | 33 /* Check whether the given locale name is recognized by the system. */ |
19595
beb2ad957aca
Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
34 # if defined _WIN32 && !defined __CYGWIN__ |
16214
ec738d6aeef5
Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
35 /* On native Windows, setlocale(category, "") looks at the system settings, |
14328
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
36 not at the environment variables. Also, when an encoding suffix such |
16358 | 37 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE |
14328
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
38 category of the locale to "C". */ |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
39 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
40 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
41 return 1; |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
42 # else |
8132 | 43 if (setlocale (LC_ALL, "") == NULL) return 1; |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
44 # endif |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
45 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16358
diff
changeset
|
46 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
47 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
48 On OpenBSD 4.0, when an unsupported locale is specified, setlocale() |
9618 | 49 succeeds but then nl_langinfo(CODESET) is "646". In this situation, |
13822
03e1d3ecee9a
Tests: Fix LOCALE_JA on MirBSD 10.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
50 some unit tests fail. |
03e1d3ecee9a
Tests: Fix LOCALE_JA on MirBSD 10.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
51 On MirBSD 10, when an unsupported locale is specified, setlocale() |
03e1d3ecee9a
Tests: Fix LOCALE_JA on MirBSD 10.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
52 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
53 # if HAVE_LANGINFO_CODESET |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
54 { |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
55 const char *cs = nl_langinfo (CODESET); |
13822
03e1d3ecee9a
Tests: Fix LOCALE_JA on MirBSD 10.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
56 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 |
03e1d3ecee9a
Tests: Fix LOCALE_JA on MirBSD 10.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
57 || strcmp (cs, "UTF-8") == 0) |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
58 return 1; |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
59 } |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
60 # endif |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
61 # ifdef __CYGWIN__ |
9356
23797caac455
Improve comments in last patch.
Bruno Haible <bruno@clisp.org>
parents:
9354
diff
changeset
|
62 /* On Cygwin, avoid locale names without encoding suffix, because the |
23797caac455
Improve comments in last patch.
Bruno Haible <bruno@clisp.org>
parents:
9354
diff
changeset
|
63 locale_charset() function relies on the encoding suffix. Note that |
23797caac455
Improve comments in last patch.
Bruno Haible <bruno@clisp.org>
parents:
9354
diff
changeset
|
64 LC_ALL is set on the command line. */ |
9354
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
65 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
66 # endif |
8132 | 67 /* Check whether in the abbreviation of the second month, the second |
68 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only | |
69 one byte long. This excludes the UTF-8 encoding. */ | |
70 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; | |
71 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; | |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
72 # if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ |
8466
c9b54316f274
Work around buggy locales in NetBSD 3.0.
Bruno Haible <bruno@clisp.org>
parents:
8149
diff
changeset
|
73 /* Check whether the decimal separator is a comma. |
c9b54316f274
Work around buggy locales in NetBSD 3.0.
Bruno Haible <bruno@clisp.org>
parents:
8149
diff
changeset
|
74 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point |
c9b54316f274
Work around buggy locales in NetBSD 3.0.
Bruno Haible <bruno@clisp.org>
parents:
8149
diff
changeset
|
75 are nl_langinfo(RADIXCHAR) are both ".". */ |
8523 | 76 if (localeconv () ->decimal_point[0] != ',') return 1; |
19269
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
77 # endif |
34621106f5e0
Avoid several test failures with traditional locales on Haiku.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
78 return 0; |
16306
78e1216a8ee3
locale-fr.m4: Fix for Android.
Bruno Haible <bruno@clisp.org>
parents:
16214
diff
changeset
|
79 #endif |
8132 | 80 } |
81 changequote([,])dnl | |
11092
baa54e3c744f
Use non-UTF-8 locales on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
82 ])]) |
baa54e3c744f
Use non-UTF-8 locales on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
83 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
84 case "$host_os" in |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
85 # Handle native Windows specially, because there setlocale() interprets |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
86 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
87 # "fr" or "fra" as "French" or "French_France.1252", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
88 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
89 # "ja" as "Japanese" or "Japanese_Japan.932", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
90 # and similar. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
91 mingw*) |
16214
ec738d6aeef5
Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
92 # Test for the native Windows locale name. |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
93 if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
94 gt_cv_locale_fr=French_France.1252 |
8132 | 95 else |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
96 # None found. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
97 gt_cv_locale_fr=none |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
98 fi |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
99 ;; |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
100 *) |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
101 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16358
diff
changeset
|
102 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
103 # configure script would override the LC_ALL setting. Likewise for |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
104 # LC_CTYPE, which is also set at the beginning of the configure script. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
105 # Test for the usual locale name. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
106 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
107 gt_cv_locale_fr=fr_FR |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
108 else |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
109 # Test for the locale name with explicit encoding suffix. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
110 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
111 gt_cv_locale_fr=fr_FR.ISO-8859-1 |
8132 | 112 else |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
113 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
114 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
115 gt_cv_locale_fr=fr_FR.ISO8859-1 |
8132 | 116 else |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
117 # Test for the HP-UX locale name. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
118 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
119 gt_cv_locale_fr=fr_FR.iso88591 |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
120 else |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
121 # Test for the Solaris 7 locale name. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
122 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
123 gt_cv_locale_fr=fr |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
124 else |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
125 # None found. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
126 gt_cv_locale_fr=none |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
127 fi |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
128 fi |
8132 | 129 fi |
130 fi | |
131 fi | |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
132 ;; |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
133 esac |
8132 | 134 fi |
11092
baa54e3c744f
Use non-UTF-8 locales on MacOS X.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
135 rm -fr conftest* |
8132 | 136 ]) |
137 LOCALE_FR=$gt_cv_locale_fr | |
138 AC_SUBST([LOCALE_FR]) | |
139 ]) | |
140 | |
141 dnl Determine the name of a french locale with UTF-8 encoding. | |
142 AC_DEFUN([gt_LOCALE_FR_UTF8], | |
143 [ | |
144 AC_REQUIRE([AM_LANGINFO_CODESET]) | |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
10962
diff
changeset
|
145 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ |
8132 | 146 AC_LANG_CONFTEST([AC_LANG_SOURCE([ |
147 changequote(,)dnl | |
148 #include <locale.h> | |
149 #include <time.h> | |
150 #if HAVE_LANGINFO_CODESET | |
151 # include <langinfo.h> | |
152 #endif | |
9354
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
153 #include <stdlib.h> |
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
154 #include <string.h> |
8132 | 155 struct tm t; |
156 char buf[16]; | |
157 int main () { | |
10962 | 158 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl |
8132 | 159 imitates locale dependent behaviour by looking at the environment |
160 variables, and all locales use the UTF-8 encoding. */ | |
10959 | 161 #if !(defined __BEOS__ || defined __HAIKU__) |
8132 | 162 /* Check whether the given locale name is recognized by the system. */ |
19595
beb2ad957aca
Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
163 # if defined _WIN32 && !defined __CYGWIN__ |
16214
ec738d6aeef5
Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
164 /* On native Windows, setlocale(category, "") looks at the system settings, |
14328
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
165 not at the environment variables. Also, when an encoding suffix such |
16358 | 166 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE |
14328
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
167 category of the locale to "C". */ |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
168 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
169 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
170 return 1; |
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
171 # else |
8132 | 172 if (setlocale (LC_ALL, "") == NULL) return 1; |
14328
0b7fb1b0ec90
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
173 # endif |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
174 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16358
diff
changeset
|
175 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
176 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
177 On OpenBSD 4.0, when an unsupported locale is specified, setlocale() |
9618 | 178 succeeds but then nl_langinfo(CODESET) is "646". In this situation, |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
179 some unit tests fail. */ |
8132 | 180 # if HAVE_LANGINFO_CODESET |
9614
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
181 { |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
182 const char *cs = nl_langinfo (CODESET); |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
183 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
184 return 1; |
e42aadd6fef7
Avoid unsupported locales on OpenBSD.
Bruno Haible <bruno@clisp.org>
parents:
9457
diff
changeset
|
185 } |
8132 | 186 # endif |
9354
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
187 # ifdef __CYGWIN__ |
9356
23797caac455
Improve comments in last patch.
Bruno Haible <bruno@clisp.org>
parents:
9354
diff
changeset
|
188 /* On Cygwin, avoid locale names without encoding suffix, because the |
23797caac455
Improve comments in last patch.
Bruno Haible <bruno@clisp.org>
parents:
9354
diff
changeset
|
189 locale_charset() function relies on the encoding suffix. Note that |
23797caac455
Improve comments in last patch.
Bruno Haible <bruno@clisp.org>
parents:
9354
diff
changeset
|
190 LC_ALL is set on the command line. */ |
9354
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
191 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; |
3af45fcfbd04
Restrict the usable locale names on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
8524
diff
changeset
|
192 # endif |
8132 | 193 /* Check whether in the abbreviation of the second month, the second |
194 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is | |
195 two bytes long, with UTF-8 encoding. */ | |
196 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; | |
197 if (strftime (buf, sizeof (buf), "%b", &t) < 4 | |
198 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') | |
199 return 1; | |
200 #endif | |
16306
78e1216a8ee3
locale-fr.m4: Fix for Android.
Bruno Haible <bruno@clisp.org>
parents:
16214
diff
changeset
|
201 #if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ |
8466
c9b54316f274
Work around buggy locales in NetBSD 3.0.
Bruno Haible <bruno@clisp.org>
parents:
8149
diff
changeset
|
202 /* Check whether the decimal separator is a comma. |
c9b54316f274
Work around buggy locales in NetBSD 3.0.
Bruno Haible <bruno@clisp.org>
parents:
8149
diff
changeset
|
203 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point |
c9b54316f274
Work around buggy locales in NetBSD 3.0.
Bruno Haible <bruno@clisp.org>
parents:
8149
diff
changeset
|
204 are nl_langinfo(RADIXCHAR) are both ".". */ |
8523 | 205 if (localeconv () ->decimal_point[0] != ',') return 1; |
16306
78e1216a8ee3
locale-fr.m4: Fix for Android.
Bruno Haible <bruno@clisp.org>
parents:
16214
diff
changeset
|
206 #endif |
8132 | 207 return 0; |
208 } | |
209 changequote([,])dnl | |
210 ])]) | |
211 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then | |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
212 case "$host_os" in |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
213 # Handle native Windows specially, because there setlocale() interprets |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
214 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
215 # "fr" or "fra" as "French" or "French_France.1252", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
216 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
217 # "ja" as "Japanese" or "Japanese_Japan.932", |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
218 # and similar. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
219 mingw*) |
16214
ec738d6aeef5
Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
220 # Test for the hypothetical native Windows locale name. |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
221 if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
222 gt_cv_locale_fr_utf8=French_France.65001 |
8132 | 223 else |
224 # None found. | |
225 gt_cv_locale_fr_utf8=none | |
226 fi | |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
227 ;; |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
228 *) |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
229 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16358
diff
changeset
|
230 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the |
14329
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
231 # configure script would override the LC_ALL setting. Likewise for |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
232 # LC_CTYPE, which is also set at the beginning of the configure script. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
233 # Test for the usual locale name. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
234 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
235 gt_cv_locale_fr_utf8=fr_FR |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
236 else |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
237 # Test for the locale name with explicit encoding suffix. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
238 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
239 gt_cv_locale_fr_utf8=fr_FR.UTF-8 |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
240 else |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
241 # Test for the Solaris 7 locale name. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
242 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
243 gt_cv_locale_fr_utf8=fr.UTF-8 |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
244 else |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
245 # None found. |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
246 gt_cv_locale_fr_utf8=none |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
247 fi |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
248 fi |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
249 fi |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
250 ;; |
9b6c354817c4
Prepare for locale dependent tests on mingw.
Bruno Haible <bruno@clisp.org>
parents:
14328
diff
changeset
|
251 esac |
8132 | 252 fi |
253 rm -fr conftest* | |
254 ]) | |
255 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 | |
256 AC_SUBST([LOCALE_FR_UTF8]) | |
257 ]) |