diff options
Diffstat (limited to 'gl/m4/mbrtowc.m4')
| -rw-r--r-- | gl/m4/mbrtowc.m4 | 215 |
1 files changed, 82 insertions, 133 deletions
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4 index bb393041..a49872fa 100644 --- a/gl/m4/mbrtowc.m4 +++ b/gl/m4/mbrtowc.m4 | |||
| @@ -1,9 +1,11 @@ | |||
| 1 | # mbrtowc.m4 serial 38 -*- coding: utf-8 -*- | 1 | # mbrtowc.m4 |
| 2 | dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation, | 2 | # serial 47 |
| 3 | dnl Copyright (C) 2001-2002, 2004-2005, 2008-2026 Free Software Foundation, | ||
| 3 | dnl Inc. | 4 | dnl Inc. |
| 4 | dnl This file is free software; the Free Software Foundation | 5 | dnl This file is free software; the Free Software Foundation |
| 5 | dnl gives unlimited permission to copy and/or distribute it, | 6 | dnl gives unlimited permission to copy and/or distribute it, |
| 6 | dnl with or without modifications, as long as this notice is preserved. | 7 | dnl with or without modifications, as long as this notice is preserved. |
| 8 | dnl This file is offered as-is, without any warranty. | ||
| 7 | 9 | ||
| 8 | AC_DEFUN([gl_FUNC_MBRTOWC], | 10 | AC_DEFUN([gl_FUNC_MBRTOWC], |
| 9 | [ | 11 | [ |
| @@ -31,7 +33,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
| 31 | REPLACE_MBRTOWC=1 | 33 | REPLACE_MBRTOWC=1 |
| 32 | else | 34 | else |
| 33 | gl_MBRTOWC_NULL_ARG1 | 35 | gl_MBRTOWC_NULL_ARG1 |
| 34 | gl_MBRTOWC_NULL_ARG2 | ||
| 35 | gl_MBRTOWC_RETVAL | 36 | gl_MBRTOWC_RETVAL |
| 36 | gl_MBRTOWC_NUL_RETVAL | 37 | gl_MBRTOWC_NUL_RETVAL |
| 37 | gl_MBRTOWC_STORES_INCOMPLETE | 38 | gl_MBRTOWC_STORES_INCOMPLETE |
| @@ -44,13 +45,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
| 44 | REPLACE_MBRTOWC=1 | 45 | REPLACE_MBRTOWC=1 |
| 45 | ;; | 46 | ;; |
| 46 | esac | 47 | esac |
| 47 | case "$gl_cv_func_mbrtowc_null_arg2" in | ||
| 48 | *yes) ;; | ||
| 49 | *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1], | ||
| 50 | [Define if the mbrtowc function has the NULL string argument bug.]) | ||
| 51 | REPLACE_MBRTOWC=1 | ||
| 52 | ;; | ||
| 53 | esac | ||
| 54 | case "$gl_cv_func_mbrtowc_retval" in | 48 | case "$gl_cv_func_mbrtowc_retval" in |
| 55 | *yes) ;; | 49 | *yes) ;; |
| 56 | *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], | 50 | *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], |
| @@ -91,20 +85,25 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
| 91 | fi | 85 | fi |
| 92 | if test $REPLACE_MBSTATE_T = 1; then | 86 | if test $REPLACE_MBSTATE_T = 1; then |
| 93 | case "$host_os" in | 87 | case "$host_os" in |
| 94 | mingw*) LIB_MBRTOWC= ;; | 88 | mingw* | windows*) |
| 89 | MBRTOWC_LIB= | ||
| 90 | ;; | ||
| 95 | *) | 91 | *) |
| 96 | gl_WEAK_SYMBOLS | 92 | gl_WEAK_SYMBOLS |
| 97 | case "$gl_cv_have_weak" in | 93 | case "$gl_cv_have_weak" in |
| 98 | *yes) LIB_MBRTOWC= ;; | 94 | *yes) MBRTOWC_LIB= ;; |
| 99 | *) LIB_MBRTOWC="$LIBPTHREAD" ;; | 95 | *) MBRTOWC_LIB="$LIBPTHREAD" ;; |
| 100 | esac | 96 | esac |
| 101 | ;; | 97 | ;; |
| 102 | esac | 98 | esac |
| 103 | else | 99 | else |
| 104 | LIB_MBRTOWC= | 100 | MBRTOWC_LIB= |
| 105 | fi | 101 | fi |
| 106 | dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX | 102 | dnl MBRTOWC_LIB is expected to be '-pthread' or '-lpthread' on AIX |
| 107 | dnl with gcc or xlc, and empty otherwise. | 103 | dnl with gcc or xlc, and empty otherwise. |
| 104 | AC_SUBST([MBRTOWC_LIB]) | ||
| 105 | dnl For backward compatibility. | ||
| 106 | LIB_MBRTOWC="$MBRTOWC_LIB" | ||
| 108 | AC_SUBST([LIB_MBRTOWC]) | 107 | AC_SUBST([LIB_MBRTOWC]) |
| 109 | ]) | 108 | ]) |
| 110 | 109 | ||
| @@ -114,7 +113,7 @@ dnl Result is REPLACE_MBSTATE_T. | |||
| 114 | dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to | 113 | dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to |
| 115 | dnl avoid inconsistencies. | 114 | dnl avoid inconsistencies. |
| 116 | 115 | ||
| 117 | AC_DEFUN([gl_MBSTATE_T_BROKEN], | 116 | AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN], |
| 118 | [ | 117 | [ |
| 119 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | 118 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
| 120 | AC_REQUIRE([AC_CANONICAL_HOST]) | 119 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| @@ -126,7 +125,7 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN], | |||
| 126 | dnl to override it, even if - like on MSVC - mbsinit() is only defined as | 125 | dnl to override it, even if - like on MSVC - mbsinit() is only defined as |
| 127 | dnl an inline function, not as a global function. | 126 | dnl an inline function, not as a global function. |
| 128 | if case "$host_os" in | 127 | if case "$host_os" in |
| 129 | mingw*) true ;; | 128 | mingw* | windows*) true ;; |
| 130 | *) test $ac_cv_func_mbsinit = yes ;; | 129 | *) test $ac_cv_func_mbsinit = yes ;; |
| 131 | esac \ | 130 | esac \ |
| 132 | && test $ac_cv_func_mbrtowc = yes; then | 131 | && test $ac_cv_func_mbrtowc = yes; then |
| @@ -154,7 +153,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], | |||
| 154 | [ | 153 | [ |
| 155 | AC_REQUIRE([AC_PROG_CC]) | 154 | AC_REQUIRE([AC_PROG_CC]) |
| 156 | AC_REQUIRE([gt_LOCALE_JA]) | 155 | AC_REQUIRE([gt_LOCALE_JA]) |
| 157 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | 156 | AC_REQUIRE([gt_LOCALE_EN_UTF8]) |
| 158 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 157 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 159 | AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], | 158 | AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], |
| 160 | [gl_cv_func_mbrtowc_incomplete_state], | 159 | [gl_cv_func_mbrtowc_incomplete_state], |
| @@ -163,10 +162,10 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], | |||
| 163 | dnl is present. | 162 | dnl is present. |
| 164 | changequote(,)dnl | 163 | changequote(,)dnl |
| 165 | case "$host_os" in | 164 | case "$host_os" in |
| 166 | # Guess no on AIX and OSF/1. | 165 | # Guess no on AIX. |
| 167 | aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; | 166 | aix*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; |
| 168 | # Guess yes otherwise. | 167 | # Guess yes otherwise. |
| 169 | *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; | 168 | *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; |
| 170 | esac | 169 | esac |
| 171 | changequote([,])dnl | 170 | changequote([,])dnl |
| 172 | if test $LOCALE_JA != none; then | 171 | if test $LOCALE_JA != none; then |
| @@ -194,7 +193,7 @@ int main () | |||
| 194 | [gl_cv_func_mbrtowc_incomplete_state=no], | 193 | [gl_cv_func_mbrtowc_incomplete_state=no], |
| 195 | [:]) | 194 | [:]) |
| 196 | else | 195 | else |
| 197 | if test $LOCALE_FR_UTF8 != none; then | 196 | if test "$LOCALE_EN_UTF8" != none; then |
| 198 | AC_RUN_IFELSE( | 197 | AC_RUN_IFELSE( |
| 199 | [AC_LANG_SOURCE([[ | 198 | [AC_LANG_SOURCE([[ |
| 200 | #include <locale.h> | 199 | #include <locale.h> |
| @@ -202,7 +201,7 @@ int main () | |||
| 202 | #include <wchar.h> | 201 | #include <wchar.h> |
| 203 | int main () | 202 | int main () |
| 204 | { | 203 | { |
| 205 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | 204 | if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL) |
| 206 | { | 205 | { |
| 207 | const char input[] = "B\303\274\303\237er"; /* "Büßer" */ | 206 | const char input[] = "B\303\274\303\237er"; /* "Büßer" */ |
| 208 | mbstate_t state; | 207 | mbstate_t state; |
| @@ -282,7 +281,7 @@ dnl Result is gl_cv_func_mbrtowc_null_arg1. | |||
| 282 | AC_DEFUN([gl_MBRTOWC_NULL_ARG1], | 281 | AC_DEFUN([gl_MBRTOWC_NULL_ARG1], |
| 283 | [ | 282 | [ |
| 284 | AC_REQUIRE([AC_PROG_CC]) | 283 | AC_REQUIRE([AC_PROG_CC]) |
| 285 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | 284 | AC_REQUIRE([gt_LOCALE_EN_UTF8]) |
| 286 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 285 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 287 | AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument], | 286 | AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument], |
| 288 | [gl_cv_func_mbrtowc_null_arg1], | 287 | [gl_cv_func_mbrtowc_null_arg1], |
| @@ -297,7 +296,7 @@ changequote(,)dnl | |||
| 297 | *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; | 296 | *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; |
| 298 | esac | 297 | esac |
| 299 | changequote([,])dnl | 298 | changequote([,])dnl |
| 300 | if test $LOCALE_FR_UTF8 != none; then | 299 | if test "$LOCALE_EN_UTF8" != none; then |
| 301 | AC_RUN_IFELSE( | 300 | AC_RUN_IFELSE( |
| 302 | [AC_LANG_SOURCE([[ | 301 | [AC_LANG_SOURCE([[ |
| 303 | #include <locale.h> | 302 | #include <locale.h> |
| @@ -308,7 +307,7 @@ int main () | |||
| 308 | { | 307 | { |
| 309 | int result = 0; | 308 | int result = 0; |
| 310 | 309 | ||
| 311 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | 310 | if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL) |
| 312 | { | 311 | { |
| 313 | char input[] = "\303\237er"; | 312 | char input[] = "\303\237er"; |
| 314 | mbstate_t state; | 313 | mbstate_t state; |
| @@ -339,57 +338,6 @@ int main () | |||
| 339 | ]) | 338 | ]) |
| 340 | ]) | 339 | ]) |
| 341 | 340 | ||
| 342 | dnl Test whether mbrtowc supports a NULL string argument correctly. | ||
| 343 | dnl Result is gl_cv_func_mbrtowc_null_arg2. | ||
| 344 | |||
| 345 | AC_DEFUN([gl_MBRTOWC_NULL_ARG2], | ||
| 346 | [ | ||
| 347 | AC_REQUIRE([AC_PROG_CC]) | ||
| 348 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | ||
| 349 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||
| 350 | AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument], | ||
| 351 | [gl_cv_func_mbrtowc_null_arg2], | ||
| 352 | [ | ||
| 353 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
| 354 | dnl is present. | ||
| 355 | changequote(,)dnl | ||
| 356 | case "$host_os" in | ||
| 357 | # Guess no on OSF/1. | ||
| 358 | osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;; | ||
| 359 | # Guess yes otherwise. | ||
| 360 | *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;; | ||
| 361 | esac | ||
| 362 | changequote([,])dnl | ||
| 363 | if test $LOCALE_FR_UTF8 != none; then | ||
| 364 | AC_RUN_IFELSE( | ||
| 365 | [AC_LANG_SOURCE([[ | ||
| 366 | #include <locale.h> | ||
| 367 | #include <string.h> | ||
| 368 | #include <wchar.h> | ||
| 369 | int main () | ||
| 370 | { | ||
| 371 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | ||
| 372 | { | ||
| 373 | mbstate_t state; | ||
| 374 | wchar_t wc; | ||
| 375 | int ret; | ||
| 376 | |||
| 377 | memset (&state, '\0', sizeof (mbstate_t)); | ||
| 378 | wc = (wchar_t) 0xBADFACE; | ||
| 379 | mbrtowc (&wc, NULL, 5, &state); | ||
| 380 | /* Check that wc was not modified. */ | ||
| 381 | if (wc != (wchar_t) 0xBADFACE) | ||
| 382 | return 2; | ||
| 383 | } | ||
| 384 | return 0; | ||
| 385 | }]])], | ||
| 386 | [gl_cv_func_mbrtowc_null_arg2=yes], | ||
| 387 | [gl_cv_func_mbrtowc_null_arg2=no], | ||
| 388 | [:]) | ||
| 389 | fi | ||
| 390 | ]) | ||
| 391 | ]) | ||
| 392 | |||
| 393 | dnl Test whether mbrtowc, when parsing the end of a multibyte character, | 341 | dnl Test whether mbrtowc, when parsing the end of a multibyte character, |
| 394 | dnl correctly returns the number of bytes that were needed to complete the | 342 | dnl correctly returns the number of bytes that were needed to complete the |
| 395 | dnl character (not the total number of bytes of the multibyte character). | 343 | dnl character (not the total number of bytes of the multibyte character). |
| @@ -398,7 +346,7 @@ dnl Result is gl_cv_func_mbrtowc_retval. | |||
| 398 | AC_DEFUN([gl_MBRTOWC_RETVAL], | 346 | AC_DEFUN([gl_MBRTOWC_RETVAL], |
| 399 | [ | 347 | [ |
| 400 | AC_REQUIRE([AC_PROG_CC]) | 348 | AC_REQUIRE([AC_PROG_CC]) |
| 401 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | 349 | AC_REQUIRE([gt_LOCALE_EN_UTF8]) |
| 402 | AC_REQUIRE([gt_LOCALE_JA]) | 350 | AC_REQUIRE([gt_LOCALE_JA]) |
| 403 | AC_REQUIRE([AC_CANONICAL_HOST]) | 351 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| 404 | AC_CACHE_CHECK([whether mbrtowc has a correct return value], | 352 | AC_CACHE_CHECK([whether mbrtowc has a correct return value], |
| @@ -408,14 +356,16 @@ AC_DEFUN([gl_MBRTOWC_RETVAL], | |||
| 408 | dnl is present. | 356 | dnl is present. |
| 409 | changequote(,)dnl | 357 | changequote(,)dnl |
| 410 | case "$host_os" in | 358 | case "$host_os" in |
| 411 | # Guess no on HP-UX, Solaris, native Windows. | 359 | # Guess no on HP-UX, Solaris, native Windows. |
| 412 | hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; | 360 | hpux* | solaris* | mingw* | windows*) |
| 413 | # Guess yes otherwise. | 361 | gl_cv_func_mbrtowc_retval="guessing no" ;; |
| 414 | *) gl_cv_func_mbrtowc_retval="guessing yes" ;; | 362 | # Guess yes otherwise. |
| 363 | *) | ||
| 364 | gl_cv_func_mbrtowc_retval="guessing yes" ;; | ||
| 415 | esac | 365 | esac |
| 416 | changequote([,])dnl | 366 | changequote([,])dnl |
| 417 | if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ | 367 | if test "$LOCALE_EN_UTF8" != none || test $LOCALE_JA != none \ |
| 418 | || { case "$host_os" in mingw*) true;; *) false;; esac; }; then | 368 | || { case "$host_os" in mingw* | windows*) true;; *) false;; esac; }; then |
| 419 | AC_RUN_IFELSE( | 369 | AC_RUN_IFELSE( |
| 420 | [AC_LANG_SOURCE([[ | 370 | [AC_LANG_SOURCE([[ |
| 421 | #include <locale.h> | 371 | #include <locale.h> |
| @@ -426,7 +376,8 @@ int main () | |||
| 426 | int result = 0; | 376 | int result = 0; |
| 427 | int found_some_locale = 0; | 377 | int found_some_locale = 0; |
| 428 | /* This fails on Solaris. */ | 378 | /* This fails on Solaris. */ |
| 429 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | 379 | if (strcmp ("$LOCALE_EN_UTF8", "none") != 0 |
| 380 | && setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL) | ||
| 430 | { | 381 | { |
| 431 | char input[] = "B\303\274\303\237er"; /* "Büßer" */ | 382 | char input[] = "B\303\274\303\237er"; /* "Büßer" */ |
| 432 | mbstate_t state; | 383 | mbstate_t state; |
| @@ -442,7 +393,8 @@ int main () | |||
| 442 | found_some_locale = 1; | 393 | found_some_locale = 1; |
| 443 | } | 394 | } |
| 444 | /* This fails on HP-UX 11.11. */ | 395 | /* This fails on HP-UX 11.11. */ |
| 445 | if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) | 396 | if (strcmp ("$LOCALE_JA", "none") != 0 |
| 397 | && setlocale (LC_ALL, "$LOCALE_JA") != NULL) | ||
| 446 | { | 398 | { |
| 447 | char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ | 399 | char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ |
| 448 | mbstate_t state; | 400 | mbstate_t state; |
| @@ -577,13 +529,13 @@ AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE], | |||
| 577 | dnl is present. | 529 | dnl is present. |
| 578 | changequote(,)dnl | 530 | changequote(,)dnl |
| 579 | case "$host_os" in | 531 | case "$host_os" in |
| 580 | # Guess yes on native Windows. | 532 | # Guess yes on native Windows. |
| 581 | mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; | 533 | mingw* | windows*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; |
| 582 | *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; | 534 | *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; |
| 583 | esac | 535 | esac |
| 584 | changequote([,])dnl | 536 | changequote([,])dnl |
| 585 | case "$host_os" in | 537 | case "$host_os" in |
| 586 | mingw*) | 538 | mingw* | windows*) |
| 587 | AC_RUN_IFELSE( | 539 | AC_RUN_IFELSE( |
| 588 | [AC_LANG_SOURCE([[ | 540 | [AC_LANG_SOURCE([[ |
| 589 | #include <locale.h> | 541 | #include <locale.h> |
| @@ -639,8 +591,8 @@ int main () | |||
| 639 | [:]) | 591 | [:]) |
| 640 | ;; | 592 | ;; |
| 641 | *) | 593 | *) |
| 642 | AC_REQUIRE([gt_LOCALE_FR_UTF8]) | 594 | AC_REQUIRE([gt_LOCALE_EN_UTF8]) |
| 643 | if test $LOCALE_FR_UTF8 != none; then | 595 | if test "$LOCALE_EN_UTF8" != none; then |
| 644 | AC_RUN_IFELSE( | 596 | AC_RUN_IFELSE( |
| 645 | [AC_LANG_SOURCE([[ | 597 | [AC_LANG_SOURCE([[ |
| 646 | #include <locale.h> | 598 | #include <locale.h> |
| @@ -648,7 +600,7 @@ int main () | |||
| 648 | #include <wchar.h> | 600 | #include <wchar.h> |
| 649 | int main () | 601 | int main () |
| 650 | { | 602 | { |
| 651 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | 603 | if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL) |
| 652 | { | 604 | { |
| 653 | wchar_t wc = (wchar_t) 0xBADFACE; | 605 | wchar_t wc = (wchar_t) 0xBADFACE; |
| 654 | mbstate_t state; | 606 | mbstate_t state; |
| @@ -677,50 +629,46 @@ AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT], | |||
| 677 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 629 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 678 | AC_CACHE_CHECK([whether mbrtowc works on empty input], | 630 | AC_CACHE_CHECK([whether mbrtowc works on empty input], |
| 679 | [gl_cv_func_mbrtowc_empty_input], | 631 | [gl_cv_func_mbrtowc_empty_input], |
| 680 | [ | 632 | [AC_RUN_IFELSE( |
| 681 | dnl Initial guess, used when cross-compiling or when no suitable locale | 633 | [AC_LANG_SOURCE([[ |
| 682 | dnl is present. | 634 | #include <wchar.h> |
| 683 | changequote(,)dnl | 635 | static wchar_t wc; |
| 684 | case "$host_os" in | 636 | static mbstate_t mbs; |
| 685 | # Guess no on AIX and glibc systems. | 637 | int |
| 686 | aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; | 638 | main (void) |
| 687 | # Guess yes on native Windows. | 639 | { |
| 688 | mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; | 640 | return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; |
| 689 | *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; | 641 | }]])], |
| 690 | esac | 642 | [gl_cv_func_mbrtowc_empty_input=yes], |
| 691 | changequote([,])dnl | 643 | [gl_cv_func_mbrtowc_empty_input=no], |
| 692 | AC_RUN_IFELSE( | 644 | [case "$host_os" in |
| 693 | [AC_LANG_SOURCE([[ | 645 | # Guess no on AIX and glibc systems. |
| 694 | #include <wchar.h> | 646 | aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
| 695 | static wchar_t wc; | 647 | # Guess no on Android. |
| 696 | static mbstate_t mbs; | 648 | linux*-android*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
| 697 | int | 649 | # Guess no on native Windows. |
| 698 | main (void) | 650 | mingw* | windows*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
| 699 | { | 651 | *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; |
| 700 | return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; | 652 | esac |
| 701 | }]])], | 653 | ]) |
| 702 | [gl_cv_func_mbrtowc_empty_input=yes], | ||
| 703 | [gl_cv_func_mbrtowc_empty_input=no], | ||
| 704 | [:]) | ||
| 705 | ]) | 654 | ]) |
| 706 | ]) | 655 | ]) |
| 707 | 656 | ||
| 708 | dnl Test whether mbrtowc reports encoding errors in the C locale. | 657 | dnl Test whether mbrtowc reports encoding errors in the C locale. |
| 709 | dnl Although POSIX was never intended to allow this, the GNU C Library | 658 | dnl Although POSIX was never intended to allow this, the GNU C Library |
| 710 | dnl and other implementations do it. See: | 659 | dnl and other implementations do it. See: |
| 711 | dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 | 660 | dnl https://sourceware.org/PR19932 |
| 661 | dnl POSIX has now clarified it: | ||
| 662 | dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html> | ||
| 663 | dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte | ||
| 664 | dnl values are valid characters." | ||
| 712 | 665 | ||
| 713 | AC_DEFUN([gl_MBRTOWC_C_LOCALE], | 666 | AC_DEFUN([gl_MBRTOWC_C_LOCALE], |
| 714 | [ | 667 | [ |
| 715 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 668 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 716 | AC_CACHE_CHECK([whether the C locale is free of encoding errors], | 669 | AC_CACHE_CHECK([whether the C locale is free of encoding errors], |
| 717 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], | 670 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], |
| 718 | [ | 671 | [AC_RUN_IFELSE( |
| 719 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
| 720 | dnl is present. | ||
| 721 | gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" | ||
| 722 | |||
| 723 | AC_RUN_IFELSE( | ||
| 724 | [AC_LANG_PROGRAM( | 672 | [AC_LANG_PROGRAM( |
| 725 | [[#include <limits.h> | 673 | [[#include <limits.h> |
| 726 | #include <locale.h> | 674 | #include <locale.h> |
| @@ -741,13 +689,14 @@ AC_DEFUN([gl_MBRTOWC_C_LOCALE], | |||
| 741 | } | 689 | } |
| 742 | return 0; | 690 | return 0; |
| 743 | ]])], | 691 | ]])], |
| 744 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], | 692 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], |
| 745 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], | 693 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], |
| 746 | [case "$host_os" in | 694 | [case "$host_os" in |
| 747 | # Guess yes on native Windows. | 695 | # Guess yes on native Windows. |
| 748 | mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; | 696 | mingw* | windows*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; |
| 749 | esac | 697 | *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; |
| 750 | ]) | 698 | esac |
| 699 | ]) | ||
| 751 | ]) | 700 | ]) |
| 752 | ]) | 701 | ]) |
| 753 | 702 | ||
