diff options
Diffstat (limited to 'gl/m4/mbrtowc.m4')
| -rw-r--r-- | gl/m4/mbrtowc.m4 | 123 |
1 files changed, 65 insertions, 58 deletions
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4 index bb393041..62c4fdb3 100644 --- a/gl/m4/mbrtowc.m4 +++ b/gl/m4/mbrtowc.m4 | |||
| @@ -1,5 +1,6 @@ | |||
| 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 44 -*- coding: utf-8 -*- |
| 3 | dnl Copyright (C) 2001-2002, 2004-2005, 2008-2024 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, |
| @@ -91,20 +92,25 @@ AC_DEFUN([gl_FUNC_MBRTOWC], | |||
| 91 | fi | 92 | fi |
| 92 | if test $REPLACE_MBSTATE_T = 1; then | 93 | if test $REPLACE_MBSTATE_T = 1; then |
| 93 | case "$host_os" in | 94 | case "$host_os" in |
| 94 | mingw*) LIB_MBRTOWC= ;; | 95 | mingw* | windows*) |
| 96 | MBRTOWC_LIB= | ||
| 97 | ;; | ||
| 95 | *) | 98 | *) |
| 96 | gl_WEAK_SYMBOLS | 99 | gl_WEAK_SYMBOLS |
| 97 | case "$gl_cv_have_weak" in | 100 | case "$gl_cv_have_weak" in |
| 98 | *yes) LIB_MBRTOWC= ;; | 101 | *yes) MBRTOWC_LIB= ;; |
| 99 | *) LIB_MBRTOWC="$LIBPTHREAD" ;; | 102 | *) MBRTOWC_LIB="$LIBPTHREAD" ;; |
| 100 | esac | 103 | esac |
| 101 | ;; | 104 | ;; |
| 102 | esac | 105 | esac |
| 103 | else | 106 | else |
| 104 | LIB_MBRTOWC= | 107 | MBRTOWC_LIB= |
| 105 | fi | 108 | fi |
| 106 | dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX | 109 | dnl MBRTOWC_LIB is expected to be '-pthread' or '-lpthread' on AIX |
| 107 | dnl with gcc or xlc, and empty otherwise. | 110 | dnl with gcc or xlc, and empty otherwise. |
| 111 | AC_SUBST([MBRTOWC_LIB]) | ||
| 112 | dnl For backward compatibility. | ||
| 113 | LIB_MBRTOWC="$MBRTOWC_LIB" | ||
| 108 | AC_SUBST([LIB_MBRTOWC]) | 114 | AC_SUBST([LIB_MBRTOWC]) |
| 109 | ]) | 115 | ]) |
| 110 | 116 | ||
| @@ -114,7 +120,7 @@ dnl Result is REPLACE_MBSTATE_T. | |||
| 114 | dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to | 120 | dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to |
| 115 | dnl avoid inconsistencies. | 121 | dnl avoid inconsistencies. |
| 116 | 122 | ||
| 117 | AC_DEFUN([gl_MBSTATE_T_BROKEN], | 123 | AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN], |
| 118 | [ | 124 | [ |
| 119 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | 125 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
| 120 | AC_REQUIRE([AC_CANONICAL_HOST]) | 126 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| @@ -126,7 +132,7 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN], | |||
| 126 | dnl to override it, even if - like on MSVC - mbsinit() is only defined as | 132 | dnl to override it, even if - like on MSVC - mbsinit() is only defined as |
| 127 | dnl an inline function, not as a global function. | 133 | dnl an inline function, not as a global function. |
| 128 | if case "$host_os" in | 134 | if case "$host_os" in |
| 129 | mingw*) true ;; | 135 | mingw* | windows*) true ;; |
| 130 | *) test $ac_cv_func_mbsinit = yes ;; | 136 | *) test $ac_cv_func_mbsinit = yes ;; |
| 131 | esac \ | 137 | esac \ |
| 132 | && test $ac_cv_func_mbrtowc = yes; then | 138 | && test $ac_cv_func_mbrtowc = yes; then |
| @@ -408,14 +414,16 @@ AC_DEFUN([gl_MBRTOWC_RETVAL], | |||
| 408 | dnl is present. | 414 | dnl is present. |
| 409 | changequote(,)dnl | 415 | changequote(,)dnl |
| 410 | case "$host_os" in | 416 | case "$host_os" in |
| 411 | # Guess no on HP-UX, Solaris, native Windows. | 417 | # Guess no on HP-UX, Solaris, native Windows. |
| 412 | hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; | 418 | hpux* | solaris* | mingw* | windows*) |
| 413 | # Guess yes otherwise. | 419 | gl_cv_func_mbrtowc_retval="guessing no" ;; |
| 414 | *) gl_cv_func_mbrtowc_retval="guessing yes" ;; | 420 | # Guess yes otherwise. |
| 421 | *) | ||
| 422 | gl_cv_func_mbrtowc_retval="guessing yes" ;; | ||
| 415 | esac | 423 | esac |
| 416 | changequote([,])dnl | 424 | changequote([,])dnl |
| 417 | if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ | 425 | if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ |
| 418 | || { case "$host_os" in mingw*) true;; *) false;; esac; }; then | 426 | || { case "$host_os" in mingw* | windows*) true;; *) false;; esac; }; then |
| 419 | AC_RUN_IFELSE( | 427 | AC_RUN_IFELSE( |
| 420 | [AC_LANG_SOURCE([[ | 428 | [AC_LANG_SOURCE([[ |
| 421 | #include <locale.h> | 429 | #include <locale.h> |
| @@ -426,7 +434,8 @@ int main () | |||
| 426 | int result = 0; | 434 | int result = 0; |
| 427 | int found_some_locale = 0; | 435 | int found_some_locale = 0; |
| 428 | /* This fails on Solaris. */ | 436 | /* This fails on Solaris. */ |
| 429 | if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | 437 | if (strcmp ("$LOCALE_FR_UTF8", "none") != 0 |
| 438 | && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) | ||
| 430 | { | 439 | { |
| 431 | char input[] = "B\303\274\303\237er"; /* "Büßer" */ | 440 | char input[] = "B\303\274\303\237er"; /* "Büßer" */ |
| 432 | mbstate_t state; | 441 | mbstate_t state; |
| @@ -442,7 +451,8 @@ int main () | |||
| 442 | found_some_locale = 1; | 451 | found_some_locale = 1; |
| 443 | } | 452 | } |
| 444 | /* This fails on HP-UX 11.11. */ | 453 | /* This fails on HP-UX 11.11. */ |
| 445 | if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) | 454 | if (strcmp ("$LOCALE_JA", "none") != 0 |
| 455 | && setlocale (LC_ALL, "$LOCALE_JA") != NULL) | ||
| 446 | { | 456 | { |
| 447 | char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ | 457 | char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ |
| 448 | mbstate_t state; | 458 | mbstate_t state; |
| @@ -577,13 +587,13 @@ AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE], | |||
| 577 | dnl is present. | 587 | dnl is present. |
| 578 | changequote(,)dnl | 588 | changequote(,)dnl |
| 579 | case "$host_os" in | 589 | case "$host_os" in |
| 580 | # Guess yes on native Windows. | 590 | # Guess yes on native Windows. |
| 581 | mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; | 591 | mingw* | windows*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; |
| 582 | *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; | 592 | *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; |
| 583 | esac | 593 | esac |
| 584 | changequote([,])dnl | 594 | changequote([,])dnl |
| 585 | case "$host_os" in | 595 | case "$host_os" in |
| 586 | mingw*) | 596 | mingw* | windows*) |
| 587 | AC_RUN_IFELSE( | 597 | AC_RUN_IFELSE( |
| 588 | [AC_LANG_SOURCE([[ | 598 | [AC_LANG_SOURCE([[ |
| 589 | #include <locale.h> | 599 | #include <locale.h> |
| @@ -677,31 +687,28 @@ AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT], | |||
| 677 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 687 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 678 | AC_CACHE_CHECK([whether mbrtowc works on empty input], | 688 | AC_CACHE_CHECK([whether mbrtowc works on empty input], |
| 679 | [gl_cv_func_mbrtowc_empty_input], | 689 | [gl_cv_func_mbrtowc_empty_input], |
| 680 | [ | 690 | [AC_RUN_IFELSE( |
| 681 | dnl Initial guess, used when cross-compiling or when no suitable locale | 691 | [AC_LANG_SOURCE([[ |
| 682 | dnl is present. | 692 | #include <wchar.h> |
| 683 | changequote(,)dnl | 693 | static wchar_t wc; |
| 684 | case "$host_os" in | 694 | static mbstate_t mbs; |
| 685 | # Guess no on AIX and glibc systems. | 695 | int |
| 686 | aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; | 696 | main (void) |
| 687 | # Guess yes on native Windows. | 697 | { |
| 688 | mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; | 698 | return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; |
| 689 | *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; | 699 | }]])], |
| 690 | esac | 700 | [gl_cv_func_mbrtowc_empty_input=yes], |
| 691 | changequote([,])dnl | 701 | [gl_cv_func_mbrtowc_empty_input=no], |
| 692 | AC_RUN_IFELSE( | 702 | [case "$host_os" in |
| 693 | [AC_LANG_SOURCE([[ | 703 | # Guess no on AIX and glibc systems. |
| 694 | #include <wchar.h> | 704 | aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
| 695 | static wchar_t wc; | 705 | # Guess no on Android. |
| 696 | static mbstate_t mbs; | 706 | linux*-android*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
| 697 | int | 707 | # Guess no on native Windows. |
| 698 | main (void) | 708 | mingw* | windows*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
| 699 | { | 709 | *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; |
| 700 | return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; | 710 | esac |
| 701 | }]])], | 711 | ]) |
| 702 | [gl_cv_func_mbrtowc_empty_input=yes], | ||
| 703 | [gl_cv_func_mbrtowc_empty_input=no], | ||
| 704 | [:]) | ||
| 705 | ]) | 712 | ]) |
| 706 | ]) | 713 | ]) |
| 707 | 714 | ||
| @@ -709,18 +716,17 @@ 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 | 716 | dnl Although POSIX was never intended to allow this, the GNU C Library |
| 710 | dnl and other implementations do it. See: | 717 | dnl and other implementations do it. See: |
| 711 | dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 | 718 | dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 |
| 719 | dnl POSIX has now clarified it: | ||
| 720 | dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html> | ||
| 721 | dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte | ||
| 722 | dnl values are valid characters." | ||
| 712 | 723 | ||
| 713 | AC_DEFUN([gl_MBRTOWC_C_LOCALE], | 724 | AC_DEFUN([gl_MBRTOWC_C_LOCALE], |
| 714 | [ | 725 | [ |
| 715 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 726 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 716 | AC_CACHE_CHECK([whether the C locale is free of encoding errors], | 727 | AC_CACHE_CHECK([whether the C locale is free of encoding errors], |
| 717 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], | 728 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], |
| 718 | [ | 729 | [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( | 730 | [AC_LANG_PROGRAM( |
| 725 | [[#include <limits.h> | 731 | [[#include <limits.h> |
| 726 | #include <locale.h> | 732 | #include <locale.h> |
| @@ -741,13 +747,14 @@ AC_DEFUN([gl_MBRTOWC_C_LOCALE], | |||
| 741 | } | 747 | } |
| 742 | return 0; | 748 | return 0; |
| 743 | ]])], | 749 | ]])], |
| 744 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], | 750 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], |
| 745 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], | 751 | [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], |
| 746 | [case "$host_os" in | 752 | [case "$host_os" in |
| 747 | # Guess yes on native Windows. | 753 | # Guess yes on native Windows. |
| 748 | mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; | 754 | mingw* | windows*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; |
| 749 | esac | 755 | *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; |
| 750 | ]) | 756 | esac |
| 757 | ]) | ||
| 751 | ]) | 758 | ]) |
| 752 | ]) | 759 | ]) |
| 753 | 760 | ||
