Mercurial > hg > octave-jordi > gnulib-hg
annotate m4/mbsrtowcs.m4 @ 17954:65f6122c1b68
sync gettext .m4 files from gettext
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Tue, 07 Apr 2015 09:46:17 -0700 |
parents | ab58d4870664 |
children |
rev | line source |
---|---|
15483
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
1 # mbsrtowcs.m4 serial 13 |
17848 | 2 dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. |
10913 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 AC_DEFUN([gl_FUNC_MBSRTOWCS], | |
8 [ | |
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | |
10 | |
11 AC_REQUIRE([AC_TYPE_MBSTATE_T]) | |
10925
c8051e85cbfd
Override mbsrtowcs when redefining mbstate_t.
Bruno Haible <bruno@clisp.org>
parents:
10913
diff
changeset
|
12 gl_MBSTATE_T_BROKEN |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
13 |
10913 | 14 AC_CHECK_FUNCS_ONCE([mbsrtowcs]) |
15 if test $ac_cv_func_mbsrtowcs = no; then | |
16 HAVE_MBSRTOWCS=0 | |
15483
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
17 AC_CHECK_DECLS([mbsrtowcs],,, [[ |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
18 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
19 <wchar.h>. |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
21 included before <wchar.h>. */ |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
22 #include <stddef.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
23 #include <stdio.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
24 #include <time.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
25 #include <wchar.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
26 ]]) |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
27 if test $ac_cv_have_decl_mbsrtowcs = yes; then |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
28 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsrtowcs() although |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
29 dnl it does not have the function. Avoid a collision with gnulib's |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
30 dnl replacement. |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
31 REPLACE_MBSRTOWCS=1 |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15033
diff
changeset
|
32 fi |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
33 else |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 if test $REPLACE_MBSTATE_T = 1; then |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 REPLACE_MBSRTOWCS=1 |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 else |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 gl_MBSRTOWCS_WORKS |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
38 case "$gl_cv_func_mbsrtowcs_works" in |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
39 *yes) ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
40 *) REPLACE_MBSRTOWCS=1 ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
41 esac |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
42 fi |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
43 fi |
10913 | 44 ]) |
45 | |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
46 dnl Test whether mbsrtowcs works. |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
47 dnl Result is gl_cv_func_mbsrtowcs_works. |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
48 |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
49 AC_DEFUN([gl_MBSRTOWCS_WORKS], |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
50 [ |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
51 AC_REQUIRE([AC_PROG_CC]) |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
52 AC_REQUIRE([gt_LOCALE_FR]) |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
53 AC_REQUIRE([gt_LOCALE_FR_UTF8]) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
54 AC_REQUIRE([gt_LOCALE_JA]) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
55 AC_REQUIRE([gt_LOCALE_ZH_CN]) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
56 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
57 AC_CACHE_CHECK([whether mbsrtowcs works], |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
58 [gl_cv_func_mbsrtowcs_works], |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
59 [ |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
60 dnl Initial guess, used when cross-compiling or when no suitable locale |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
61 dnl is present. |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
62 changequote(,)dnl |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
63 case "$host_os" in |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
64 # Guess no on HP-UX, Solaris, mingw. |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
65 hpux* | solaris* | mingw*) gl_cv_func_mbsrtowcs_works="guessing no" ;; |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
66 # Guess yes otherwise. |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
67 *) gl_cv_func_mbsrtowcs_works="guessing yes" ;; |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
68 esac |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
69 changequote([,])dnl |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
70 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
71 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
72 [AC_LANG_SOURCE([[ |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
73 #include <locale.h> |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
74 #include <string.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
75 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
76 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
77 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
78 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
79 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
80 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
81 #include <time.h> |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
82 #include <wchar.h> |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
83 int main () |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
84 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
85 int result = 0; |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
86 /* Test whether the function supports a NULL destination argument. |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
87 This fails on native Windows. */ |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
88 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
89 { |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
90 const char input[] = "\337er"; |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
91 const char *src = input; |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
92 mbstate_t state; |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
93 |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
94 memset (&state, '\0', sizeof (mbstate_t)); |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
95 if (mbsrtowcs (NULL, &src, 1, &state) != 3 |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
96 || src != input) |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
97 result |= 1; |
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
98 } |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
99 /* Test whether the function works when started with a conversion state |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
100 in non-initial state. This fails on HP-UX 11.11 and Solaris 10. */ |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
101 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
102 { |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
103 const char input[] = "B\303\274\303\237er"; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
104 mbstate_t state; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
105 |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
106 memset (&state, '\0', sizeof (mbstate_t)); |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
107 if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
108 if (!mbsinit (&state)) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
109 { |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
110 const char *src = input + 2; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
111 if (mbsrtowcs (NULL, &src, 10, &state) != 4) |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
112 result |= 2; |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
113 } |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
114 } |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
115 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
116 { |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
117 const char input[] = "<\306\374\313\334\270\354>"; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
118 mbstate_t state; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
119 |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
120 memset (&state, '\0', sizeof (mbstate_t)); |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
121 if (mbrtowc (NULL, input + 3, 1, &state) == (size_t)(-2)) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
122 if (!mbsinit (&state)) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
123 { |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
124 const char *src = input + 4; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
125 if (mbsrtowcs (NULL, &src, 10, &state) != 3) |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
126 result |= 4; |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
127 } |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
128 } |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
129 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
130 { |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
131 const char input[] = "B\250\271\201\060\211\070er"; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
132 mbstate_t state; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
133 |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
134 memset (&state, '\0', sizeof (mbstate_t)); |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
135 if (mbrtowc (NULL, input + 1, 1, &state) == (size_t)(-2)) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
136 if (!mbsinit (&state)) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
137 { |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
138 const char *src = input + 2; |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
139 if (mbsrtowcs (NULL, &src, 10, &state) != 4) |
14336
42c6fa4a6b25
mbsrtowcs: Work around bug on native Windows.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
140 result |= 8; |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
141 } |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
142 } |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
143 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
144 }]])], |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
145 [gl_cv_func_mbsrtowcs_works=yes], |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
146 [gl_cv_func_mbsrtowcs_works=no], |
11493
fcd8e65744b2
Fix cross-compilation results.
Bruno Haible <bruno@clisp.org>
parents:
10932
diff
changeset
|
147 [:]) |
10931
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
148 fi |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
149 ]) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
150 ]) |
33d6ff26aa7b
Work around mbsrtowcs bug on various platforms.
Bruno Haible <bruno@clisp.org>
parents:
10925
diff
changeset
|
151 |
10913 | 152 # Prerequisites of lib/mbsrtowcs.c. |
153 AC_DEFUN([gl_PREREQ_MBSRTOWCS], [ | |
154 : | |
155 ]) |