summaryrefslogtreecommitdiffstats
path: root/gl/m4/wcrtomb.m4
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-03-11 11:34:47 +0100
committerGitHub <noreply@github.com>2023-03-11 11:34:47 +0100
commit75342b53853a898bdd93c7d3da9374115bab6b6d (patch)
tree0c0af2b796bcdd8ddd42187beb5badb420db8dea /gl/m4/wcrtomb.m4
parent6bbe0b7b0f609ecab831dec9be7690842bf0a0fc (diff)
parent357787868b5201ec3e874e7a225b1c944cbbdb4d (diff)
downloadmonitoring-plugins-75342b53853a898bdd93c7d3da9374115bab6b6d.tar.gz
Merge branch 'master' into patch-1
Diffstat (limited to 'gl/m4/wcrtomb.m4')
-rw-r--r--gl/m4/wcrtomb.m490
1 files changed, 62 insertions, 28 deletions
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index f56b5bae..d51b36e1 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,5 +1,5 @@
1# wcrtomb.m4 serial 11 1# wcrtomb.m4 serial 17
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,15 +15,8 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
15 if test $ac_cv_func_wcrtomb = no; then 15 if test $ac_cv_func_wcrtomb = no; then
16 HAVE_WCRTOMB=0 16 HAVE_WCRTOMB=0
17 AC_CHECK_DECLS([wcrtomb],,, [[ 17 AC_CHECK_DECLS([wcrtomb],,, [[
18/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 18 #include <wchar.h>
19 <wchar.h>. 19 ]])
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
21 included before <wchar.h>. */
22#include <stddef.h>
23#include <stdio.h>
24#include <time.h>
25#include <wchar.h>
26]])
27 if test $ac_cv_have_decl_wcrtomb = yes; then 20 if test $ac_cv_have_decl_wcrtomb = yes; then
28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although 21 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
29 dnl it does not have the function. Avoid a collision with gnulib's 22 dnl it does not have the function. Avoid a collision with gnulib's
@@ -31,17 +24,56 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
31 REPLACE_WCRTOMB=1 24 REPLACE_WCRTOMB=1
32 fi 25 fi
33 else 26 else
34 if test $REPLACE_MBSTATE_T = 1; then 27 dnl We don't actually need to override wcrtomb when redefining the semantics
35 REPLACE_WCRTOMB=1 28 dnl of the mbstate_t type. Tested on 32-bit AIX.
36 else 29 dnl if test $REPLACE_MBSTATE_T = 1; then
37 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes 30 dnl REPLACE_WCRTOMB=1
38 dnl returns 0 instead of 1. 31 dnl fi
32 if test $REPLACE_WCRTOMB = 0; then
33 dnl On Android 4.3, wcrtomb produces wrong characters in the C locale.
34 dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL)
35 dnl sometimes returns 0 instead of 1.
39 AC_REQUIRE([AC_PROG_CC]) 36 AC_REQUIRE([AC_PROG_CC])
40 AC_REQUIRE([gt_LOCALE_FR]) 37 AC_REQUIRE([gt_LOCALE_FR])
41 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 38 AC_REQUIRE([gt_LOCALE_FR_UTF8])
42 AC_REQUIRE([gt_LOCALE_JA]) 39 AC_REQUIRE([gt_LOCALE_JA])
43 AC_REQUIRE([gt_LOCALE_ZH_CN]) 40 AC_REQUIRE([gt_LOCALE_ZH_CN])
44 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 41 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
42 AC_CACHE_CHECK([whether wcrtomb works in the C locale],
43 [gl_cv_func_wcrtomb_works],
44 [AC_RUN_IFELSE(
45 [AC_LANG_SOURCE([[
46#include <string.h>
47#include <stdlib.h>
48#include <wchar.h>
49int main ()
50{
51 mbstate_t state;
52 char out[64];
53 int count;
54 memset (&state, 0, sizeof (state));
55 out[0] = 'x';
56 count = wcrtomb (out, L'a', &state);
57 return !(count == 1 && out[0] == 'a');
58}]])],
59 [gl_cv_func_wcrtomb_works=yes],
60 [gl_cv_func_wcrtomb_works=no],
61 [case "$host_os" in
62 # Guess no on Android.
63 linux*-android*) gl_cv_func_wcrtomb_works="guessing no";;
64 # Guess yes otherwise.
65 *) gl_cv_func_wcrtomb_works="guessing yes";;
66 esac
67 ])
68 ])
69 case "$gl_cv_func_wcrtomb_works" in
70 *yes) ;;
71 *) AC_DEFINE([WCRTOMB_C_LOCALE_BUG], [1],
72 [Define if the wcrtomb function does not work in the C locale.])
73 REPLACE_WCRTOMB=1 ;;
74 esac
75 fi
76 if test $REPLACE_WCRTOMB = 0; then
45 AC_CACHE_CHECK([whether wcrtomb return value is correct], 77 AC_CACHE_CHECK([whether wcrtomb return value is correct],
46 [gl_cv_func_wcrtomb_retval], 78 [gl_cv_func_wcrtomb_retval],
47 [ 79 [
@@ -49,10 +81,10 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
49 dnl is present. 81 dnl is present.
50changequote(,)dnl 82changequote(,)dnl
51 case "$host_os" in 83 case "$host_os" in
52 # Guess no on AIX 4, OSF/1 and Solaris. 84 # Guess no on AIX 4, OSF/1, Solaris, native Windows.
53 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; 85 aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;;
54 # Guess yes otherwise. 86 # Guess yes otherwise.
55 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; 87 *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
56 esac 88 esac
57changequote([,])dnl 89changequote([,])dnl
58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 90 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
@@ -60,14 +92,8 @@ changequote([,])dnl
60 [AC_LANG_SOURCE([[ 92 [AC_LANG_SOURCE([[
61#include <locale.h> 93#include <locale.h>
62#include <string.h> 94#include <string.h>
63/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
64 <wchar.h>.
65 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
66 included before <wchar.h>. */
67#include <stddef.h>
68#include <stdio.h>
69#include <time.h>
70#include <wchar.h> 95#include <wchar.h>
96#include <stdlib.h>
71int main () 97int main ()
72{ 98{
73 int result = 0; 99 int result = 0;
@@ -80,6 +106,12 @@ int main ()
80 { 106 {
81 if (wcrtomb (NULL, 0, NULL) != 1) 107 if (wcrtomb (NULL, 0, NULL) != 1)
82 result |= 2; 108 result |= 2;
109 {
110 wchar_t wc = (wchar_t) 0xBADFACE;
111 if (mbtowc (&wc, "\303\274", 2) == 2)
112 if (wcrtomb (NULL, wc, NULL) != 1)
113 result |= 2;
114 }
83 } 115 }
84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 116 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
85 { 117 {
@@ -100,7 +132,9 @@ int main ()
100 ]) 132 ])
101 case "$gl_cv_func_wcrtomb_retval" in 133 case "$gl_cv_func_wcrtomb_retval" in
102 *yes) ;; 134 *yes) ;;
103 *) REPLACE_WCRTOMB=1 ;; 135 *) AC_DEFINE([WCRTOMB_RETVAL_BUG], [1],
136 [Define if the wcrtomb function has an incorrect return value.])
137 REPLACE_WCRTOMB=1 ;;
104 esac 138 esac
105 fi 139 fi
106 fi 140 fi