diff options
Diffstat (limited to 'gl/m4/mbrtowc.m4')
-rw-r--r-- | gl/m4/mbrtowc.m4 | 81 |
1 files changed, 69 insertions, 12 deletions
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4 index 726497b6..11d7d23e 100644 --- a/gl/m4/mbrtowc.m4 +++ b/gl/m4/mbrtowc.m4 | |||
@@ -1,4 +1,4 @@ | |||
1 | # mbrtowc.m4 serial 13 | 1 | # mbrtowc.m4 serial 15 |
2 | dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
@@ -65,9 +65,15 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN], | |||
65 | AC_CHECK_FUNCS_ONCE([mbrtowc]) | 65 | AC_CHECK_FUNCS_ONCE([mbrtowc]) |
66 | if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then | 66 | if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then |
67 | gl_MBRTOWC_INCOMPLETE_STATE | 67 | gl_MBRTOWC_INCOMPLETE_STATE |
68 | gl_MBRTOWC_SANITYCHECK | ||
69 | REPLACE_MBSTATE_T=0 | ||
68 | case "$gl_cv_func_mbrtowc_incomplete_state" in | 70 | case "$gl_cv_func_mbrtowc_incomplete_state" in |
69 | *yes) REPLACE_MBSTATE_T=0 ;; | 71 | *yes) ;; |
70 | *) REPLACE_MBSTATE_T=1 ;; | 72 | *) REPLACE_MBSTATE_T=1 ;; |
73 | esac | ||
74 | case "$gl_cv_func_mbrtowc_sanitycheck" in | ||
75 | *yes) ;; | ||
76 | *) REPLACE_MBSTATE_T=1 ;; | ||
71 | esac | 77 | esac |
72 | else | 78 | else |
73 | REPLACE_MBSTATE_T=1 | 79 | REPLACE_MBSTATE_T=1 |
@@ -121,7 +127,58 @@ int main () | |||
121 | }], | 127 | }], |
122 | [gl_cv_func_mbrtowc_incomplete_state=yes], | 128 | [gl_cv_func_mbrtowc_incomplete_state=yes], |
123 | [gl_cv_func_mbrtowc_incomplete_state=no], | 129 | [gl_cv_func_mbrtowc_incomplete_state=no], |
124 | []) | 130 | [:]) |
131 | fi | ||
132 | ]) | ||
133 | ]) | ||
134 | |||
135 | dnl Test whether mbrtowc works not worse than mbtowc. | ||
136 | dnl Result is gl_cv_func_mbrtowc_sanitycheck. | ||
137 | |||
138 | AC_DEFUN([gl_MBRTOWC_SANITYCHECK], | ||
139 | [ | ||
140 | AC_REQUIRE([AC_PROG_CC]) | ||
141 | AC_REQUIRE([gt_LOCALE_ZH_CN]) | ||
142 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
143 | AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc], | ||
144 | [gl_cv_func_mbrtowc_sanitycheck], | ||
145 | [ | ||
146 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
147 | dnl is present. | ||
148 | changequote(,)dnl | ||
149 | case "$host_os" in | ||
150 | # Guess no on Solaris 8. | ||
151 | solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; | ||
152 | # Guess yes otherwise. | ||
153 | *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; | ||
154 | esac | ||
155 | changequote([,])dnl | ||
156 | if test $LOCALE_ZH_CN != none; then | ||
157 | AC_TRY_RUN([ | ||
158 | #include <locale.h> | ||
159 | #include <string.h> | ||
160 | #include <wchar.h> | ||
161 | int main () | ||
162 | { | ||
163 | /* This fails on Solaris 8: | ||
164 | mbrtowc returns 2, and sets wc to 0x00F0. | ||
165 | mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ | ||
166 | if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) | ||
167 | { | ||
168 | char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ | ||
169 | mbstate_t state; | ||
170 | wchar_t wc; | ||
171 | |||
172 | memset (&state, '\0', sizeof (mbstate_t)); | ||
173 | if (mbrtowc (&wc, input + 3, 6, &state) != 4 | ||
174 | && mbtowc (&wc, input + 3, 6) == 4) | ||
175 | return 1; | ||
176 | } | ||
177 | return 0; | ||
178 | }], | ||
179 | [gl_cv_func_mbrtowc_sanitycheck=yes], | ||
180 | [gl_cv_func_mbrtowc_sanitycheck=no], | ||
181 | [:]) | ||
125 | fi | 182 | fi |
126 | ]) | 183 | ]) |
127 | ]) | 184 | ]) |
@@ -168,7 +225,7 @@ int main () | |||
168 | return 1; | 225 | return 1; |
169 | } | 226 | } |
170 | return 0; | 227 | return 0; |
171 | }], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], []) | 228 | }], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], [:]) |
172 | fi | 229 | fi |
173 | ]) | 230 | ]) |
174 | ]) | 231 | ]) |
@@ -238,7 +295,7 @@ int main () | |||
238 | }], | 295 | }], |
239 | [gl_cv_func_mbrtowc_retval=yes], | 296 | [gl_cv_func_mbrtowc_retval=yes], |
240 | [gl_cv_func_mbrtowc_retval=no], | 297 | [gl_cv_func_mbrtowc_retval=no], |
241 | []) | 298 | [:]) |
242 | fi | 299 | fi |
243 | ]) | 300 | ]) |
244 | ]) | 301 | ]) |
@@ -258,10 +315,10 @@ AC_DEFUN([gl_MBRTOWC_NUL_RETVAL], | |||
258 | dnl is present. | 315 | dnl is present. |
259 | changequote(,)dnl | 316 | changequote(,)dnl |
260 | case "$host_os" in | 317 | case "$host_os" in |
261 | # Guess no on Solaris 9. | 318 | # Guess no on Solaris 8 and 9. |
262 | solaris2.9) gl_cv_func_mbrtowc_nul_retval="guessing no" ;; | 319 | solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;; |
263 | # Guess yes otherwise. | 320 | # Guess yes otherwise. |
264 | *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;; | 321 | *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;; |
265 | esac | 322 | esac |
266 | changequote([,])dnl | 323 | changequote([,])dnl |
267 | if test $LOCALE_ZH_CN != none; then | 324 | if test $LOCALE_ZH_CN != none; then |
@@ -271,7 +328,7 @@ changequote([,])dnl | |||
271 | #include <wchar.h> | 328 | #include <wchar.h> |
272 | int main () | 329 | int main () |
273 | { | 330 | { |
274 | /* This fails on Solaris 9. */ | 331 | /* This fails on Solaris 8 and 9. */ |
275 | if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) | 332 | if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) |
276 | { | 333 | { |
277 | mbstate_t state; | 334 | mbstate_t state; |
@@ -285,7 +342,7 @@ int main () | |||
285 | }], | 342 | }], |
286 | [gl_cv_func_mbrtowc_nul_retval=yes], | 343 | [gl_cv_func_mbrtowc_nul_retval=yes], |
287 | [gl_cv_func_mbrtowc_nul_retval=no], | 344 | [gl_cv_func_mbrtowc_nul_retval=no], |
288 | []) | 345 | [:]) |
289 | fi | 346 | fi |
290 | ]) | 347 | ]) |
291 | ]) | 348 | ]) |