summaryrefslogtreecommitdiffstats
path: root/gl/m4/wcrtomb.m4
diff options
context:
space:
mode:
authorKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 22:49:18 (GMT)
committerKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 22:49:18 (GMT)
commita0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch)
tree8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/m4/wcrtomb.m4
parentca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7.tar.gz
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
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 f56b5ba..d51b36e 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