Mercurial > gnulib
annotate m4/mbrtowc.m4 @ 40151:db994b489ff2
relocatable-prog: Use Linux code on Android.
* lib/progreloc.c: Treat Android like Linux.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 27 Jan 2019 11:37:46 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
39704
46aa87a2631e
mbrtowc, wcwidth: Fix MT-safety bug (regression from 2018-06-23).
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
1 # mbrtowc.m4 serial 31 -*- coding: utf-8 -*- |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
39704
diff
changeset
|
2 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2019 Free Software Foundation, |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
11654
diff
changeset
|
3 dnl Inc. |
5585
adff74659d81
Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents:
5018
diff
changeset
|
4 dnl This file is free software; the Free Software Foundation |
adff74659d81
Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents:
5018
diff
changeset
|
5 dnl gives unlimited permission to copy and/or distribute it, |
adff74659d81
Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents:
5018
diff
changeset
|
6 dnl with or without modifications, as long as this notice is preserved. |
3167
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
7 |
10906 | 8 AC_DEFUN([gl_FUNC_MBRTOWC], |
9 [ | |
10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | |
11 | |
12 AC_REQUIRE([AC_TYPE_MBSTATE_T]) | |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
13 gl_MBSTATE_T_BROKEN |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
14 |
10906 | 15 AC_CHECK_FUNCS_ONCE([mbrtowc]) |
16 if test $ac_cv_func_mbrtowc = no; then | |
17 HAVE_MBRTOWC=0 | |
15483
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
18 AC_CHECK_DECLS([mbrtowc],,, [[ |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
19 /* 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:
15029
diff
changeset
|
20 <wchar.h>. |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
21 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:
15029
diff
changeset
|
22 included before <wchar.h>. */ |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
23 #include <stddef.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
24 #include <stdio.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
25 #include <time.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
26 #include <wchar.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
27 ]]) |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
28 if test $ac_cv_have_decl_mbrtowc = yes; then |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
30 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:
15029
diff
changeset
|
31 dnl replacement. |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
32 REPLACE_MBRTOWC=1 |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15029
diff
changeset
|
33 fi |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 else |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 if test $REPLACE_MBSTATE_T = 1; then |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 REPLACE_MBRTOWC=1 |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 else |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
38 gl_MBRTOWC_NULL_ARG1 |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
39 gl_MBRTOWC_NULL_ARG2 |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
40 gl_MBRTOWC_RETVAL |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
41 gl_MBRTOWC_NUL_RETVAL |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
42 gl_MBRTOWC_EMPTY_INPUT |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
43 gl_MBRTOWC_C_LOCALE |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
44 case "$gl_cv_func_mbrtowc_null_arg1" in |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
45 *yes) ;; |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
46 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
47 [Define if the mbrtowc function has the NULL pwc argument bug.]) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
48 REPLACE_MBRTOWC=1 |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
49 ;; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
50 esac |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
51 case "$gl_cv_func_mbrtowc_null_arg2" in |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
52 *yes) ;; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
53 *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1], |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
54 [Define if the mbrtowc function has the NULL string argument bug.]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
55 REPLACE_MBRTOWC=1 |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
56 ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
57 esac |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
58 case "$gl_cv_func_mbrtowc_retval" in |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
59 *yes) ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
60 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
61 [Define if the mbrtowc function returns a wrong return value.]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
62 REPLACE_MBRTOWC=1 |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
63 ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
64 esac |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
65 case "$gl_cv_func_mbrtowc_nul_retval" in |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
66 *yes) ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
67 *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1], |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
68 [Define if the mbrtowc function does not return 0 for a NUL character.]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
69 REPLACE_MBRTOWC=1 |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
70 ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
71 esac |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
72 case "$gl_cv_func_mbrtowc_empty_input" in |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
73 *yes) ;; |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
74 *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1], |
17661
ec75d04b657d
mbrtowc.m4: fix a comment typo
Jim Meyering <meyering@fb.com>
parents:
17660
diff
changeset
|
75 [Define if the mbrtowc function does not return (size_t) -2 |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
76 for empty input.]) |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
77 REPLACE_MBRTOWC=1 |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
78 ;; |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
79 esac |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
80 case $gl_cv_C_locale_sans_EILSEQ in |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
81 *yes) ;; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
82 *) AC_DEFINE([C_LOCALE_MAYBE_EILSEQ], [1], |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
83 [Define to 1 if the C locale may have encoding errors.]) |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
84 REPLACE_MBRTOWC=1 |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
85 ;; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
86 esac |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
87 fi |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
88 fi |
10906 | 89 ]) |
90 | |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
91 dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
92 dnl redefines the semantics of the given mbstate_t type. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
93 dnl Result is REPLACE_MBSTATE_T. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
94 dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
95 dnl avoid inconsistencies. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
96 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
97 AC_DEFUN([gl_MBSTATE_T_BROKEN], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
98 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
99 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
100 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
101 AC_REQUIRE([AC_TYPE_MBSTATE_T]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
102 AC_CHECK_FUNCS_ONCE([mbsinit]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
103 AC_CHECK_FUNCS_ONCE([mbrtowc]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
104 if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
105 gl_MBRTOWC_INCOMPLETE_STATE |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
106 gl_MBRTOWC_SANITYCHECK |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
107 REPLACE_MBSTATE_T=0 |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
108 case "$gl_cv_func_mbrtowc_incomplete_state" in |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
109 *yes) ;; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
110 *) REPLACE_MBSTATE_T=1 ;; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
111 esac |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
112 case "$gl_cv_func_mbrtowc_sanitycheck" in |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
113 *yes) ;; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
114 *) REPLACE_MBSTATE_T=1 ;; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
115 esac |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
116 else |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
117 REPLACE_MBSTATE_T=1 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
118 fi |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
119 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
120 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
121 dnl Test whether mbrtowc puts the state into non-initial state when parsing an |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
122 dnl incomplete multibyte character. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
123 dnl Result is gl_cv_func_mbrtowc_incomplete_state. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
124 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
125 AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
126 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
127 AC_REQUIRE([AC_PROG_CC]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
128 AC_REQUIRE([gt_LOCALE_JA]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
129 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
130 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
131 [gl_cv_func_mbrtowc_incomplete_state], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
132 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
133 dnl Initial guess, used when cross-compiling or when no suitable locale |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
134 dnl is present. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
135 changequote(,)dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
136 case "$host_os" in |
13485
4098b5bb6242
mbrtowc: Fix cross-compilation guess for AIX.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
137 # Guess no on AIX and OSF/1. |
4098b5bb6242
mbrtowc: Fix cross-compilation guess for AIX.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
138 aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; |
4098b5bb6242
mbrtowc: Fix cross-compilation guess for AIX.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
139 # Guess yes otherwise. |
4098b5bb6242
mbrtowc: Fix cross-compilation guess for AIX.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
140 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
141 esac |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
142 changequote([,])dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
143 if test $LOCALE_JA != none; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
144 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
145 [AC_LANG_SOURCE([[ |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
146 #include <locale.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
147 #include <string.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
148 /* 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
|
149 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
150 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
|
151 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
152 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
153 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
154 #include <time.h> |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
155 #include <wchar.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
156 int main () |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
157 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
158 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
159 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
160 const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
161 mbstate_t state; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
162 wchar_t wc; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
163 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
164 memset (&state, '\0', sizeof (mbstate_t)); |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
165 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
166 if (mbsinit (&state)) |
18530
4cb1f97031ad
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18292
diff
changeset
|
167 return 2; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
168 } |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
169 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
170 }]])], |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
171 [gl_cv_func_mbrtowc_incomplete_state=yes], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
172 [gl_cv_func_mbrtowc_incomplete_state=no], |
11493
fcd8e65744b2
Fix cross-compilation results.
Bruno Haible <bruno@clisp.org>
parents:
11218
diff
changeset
|
173 [:]) |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
174 fi |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
175 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
176 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
177 |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
178 dnl Test whether mbrtowc works not worse than mbtowc. |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
179 dnl Result is gl_cv_func_mbrtowc_sanitycheck. |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
180 |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
181 AC_DEFUN([gl_MBRTOWC_SANITYCHECK], |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
182 [ |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
183 AC_REQUIRE([AC_PROG_CC]) |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
184 AC_REQUIRE([gt_LOCALE_ZH_CN]) |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
185 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
186 AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc], |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
187 [gl_cv_func_mbrtowc_sanitycheck], |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
188 [ |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
189 dnl Initial guess, used when cross-compiling or when no suitable locale |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
190 dnl is present. |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
191 changequote(,)dnl |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
192 case "$host_os" in |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
193 # Guess no on Solaris 8. |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
194 solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
195 # Guess yes otherwise. |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
196 *) gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
197 esac |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
198 changequote([,])dnl |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
199 if test $LOCALE_ZH_CN != none; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
200 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
201 [AC_LANG_SOURCE([[ |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
202 #include <locale.h> |
11654
22347e3d6b95
Make the tests work with a C++ compiler.
Sam Steingold <sds@gnu.org>
parents:
11493
diff
changeset
|
203 #include <stdlib.h> |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
204 #include <string.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
205 /* 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
|
206 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
207 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
|
208 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
209 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
210 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
211 #include <time.h> |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
212 #include <wchar.h> |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
213 int main () |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
214 { |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
215 /* This fails on Solaris 8: |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
216 mbrtowc returns 2, and sets wc to 0x00F0. |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
217 mbtowc returns 4 (correct) and sets wc to 0x5EDC. */ |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
218 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
219 { |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
220 char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
221 mbstate_t state; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
222 wchar_t wc; |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
223 |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
224 memset (&state, '\0', sizeof (mbstate_t)); |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
225 if (mbrtowc (&wc, input + 3, 6, &state) != 4 |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
226 && mbtowc (&wc, input + 3, 6) == 4) |
18530
4cb1f97031ad
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18292
diff
changeset
|
227 return 2; |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
228 } |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
229 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
230 }]])], |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
231 [gl_cv_func_mbrtowc_sanitycheck=yes], |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
232 [gl_cv_func_mbrtowc_sanitycheck=no], |
11493
fcd8e65744b2
Fix cross-compilation results.
Bruno Haible <bruno@clisp.org>
parents:
11218
diff
changeset
|
233 [:]) |
11217
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
234 fi |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
235 ]) |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
236 ]) |
13e9d2ea1d1d
Work around mbrtowc bug in zh_CN.GB18030 locale on Solaris 8.
Bruno Haible <bruno@clisp.org>
parents:
11007
diff
changeset
|
237 |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
238 dnl Test whether mbrtowc supports a NULL pwc argument correctly. |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
239 dnl Result is gl_cv_func_mbrtowc_null_arg1. |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
240 |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
241 AC_DEFUN([gl_MBRTOWC_NULL_ARG1], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
242 [ |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
243 AC_REQUIRE([AC_PROG_CC]) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
244 AC_REQUIRE([gt_LOCALE_FR_UTF8]) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
245 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
246 AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
247 [gl_cv_func_mbrtowc_null_arg1], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
248 [ |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
249 dnl Initial guess, used when cross-compiling or when no suitable locale |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
250 dnl is present. |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
251 changequote(,)dnl |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
252 case "$host_os" in |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
253 # Guess no on Solaris. |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
254 solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
255 # Guess yes otherwise. |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
256 *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
257 esac |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
258 changequote([,])dnl |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
259 if test $LOCALE_FR_UTF8 != none; then |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
260 AC_RUN_IFELSE( |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
261 [AC_LANG_SOURCE([[ |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
262 #include <locale.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
263 #include <stdlib.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
264 #include <string.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
265 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
266 <wchar.h>. |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
267 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
268 included before <wchar.h>. */ |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
269 #include <stddef.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
270 #include <stdio.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
271 #include <time.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
272 #include <wchar.h> |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
273 int main () |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
274 { |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
275 int result = 0; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
276 |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
277 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
278 { |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
279 char input[] = "\303\237er"; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
280 mbstate_t state; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
281 wchar_t wc; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
282 size_t ret; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
283 |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
284 memset (&state, '\0', sizeof (mbstate_t)); |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
285 wc = (wchar_t) 0xBADFACE; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
286 ret = mbrtowc (&wc, input, 5, &state); |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
287 if (ret != 2) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
288 result |= 1; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
289 if (!mbsinit (&state)) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
290 result |= 2; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
291 |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
292 memset (&state, '\0', sizeof (mbstate_t)); |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
293 ret = mbrtowc (NULL, input, 5, &state); |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
294 if (ret != 2) /* Solaris 7 fails here: ret is -1. */ |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
295 result |= 4; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
296 if (!mbsinit (&state)) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
297 result |= 8; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
298 } |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
299 return result; |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
300 }]])], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
301 [gl_cv_func_mbrtowc_null_arg1=yes], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
302 [gl_cv_func_mbrtowc_null_arg1=no], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
303 [:]) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
304 fi |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
305 ]) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
306 ]) |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
307 |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
308 dnl Test whether mbrtowc supports a NULL string argument correctly. |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
309 dnl Result is gl_cv_func_mbrtowc_null_arg2. |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
310 |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
311 AC_DEFUN([gl_MBRTOWC_NULL_ARG2], |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
312 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
313 AC_REQUIRE([AC_PROG_CC]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
314 AC_REQUIRE([gt_LOCALE_FR_UTF8]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
315 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
316 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument], |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
317 [gl_cv_func_mbrtowc_null_arg2], |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
318 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
319 dnl Initial guess, used when cross-compiling or when no suitable locale |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
320 dnl is present. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
321 changequote(,)dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
322 case "$host_os" in |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
323 # Guess no on OSF/1. |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
324 osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
325 # Guess yes otherwise. |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
326 *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
327 esac |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
328 changequote([,])dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
329 if test $LOCALE_FR_UTF8 != none; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
330 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
331 [AC_LANG_SOURCE([[ |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
332 #include <locale.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
333 #include <string.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
334 /* 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
|
335 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
336 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
|
337 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
338 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
339 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
340 #include <time.h> |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
341 #include <wchar.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
342 int main () |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
343 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
344 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
345 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
346 mbstate_t state; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
347 wchar_t wc; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
348 int ret; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
349 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
350 memset (&state, '\0', sizeof (mbstate_t)); |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
351 wc = (wchar_t) 0xBADFACE; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
352 mbrtowc (&wc, NULL, 5, &state); |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
353 /* Check that wc was not modified. */ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
354 if (wc != (wchar_t) 0xBADFACE) |
18530
4cb1f97031ad
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18292
diff
changeset
|
355 return 2; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
356 } |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
357 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
358 }]])], |
14042
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
359 [gl_cv_func_mbrtowc_null_arg2=yes], |
1a75c9206d28
mbrtowc: Work around a Solaris 7 bug.
Bruno Haible <bruno@clisp.org>
parents:
14020
diff
changeset
|
360 [gl_cv_func_mbrtowc_null_arg2=no], |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
361 [:]) |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
362 fi |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
363 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
364 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
365 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
366 dnl Test whether mbrtowc, when parsing the end of a multibyte character, |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
367 dnl correctly returns the number of bytes that were needed to complete the |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
368 dnl character (not the total number of bytes of the multibyte character). |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
369 dnl Result is gl_cv_func_mbrtowc_retval. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
370 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
371 AC_DEFUN([gl_MBRTOWC_RETVAL], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
372 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
373 AC_REQUIRE([AC_PROG_CC]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
374 AC_REQUIRE([gt_LOCALE_FR_UTF8]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
375 AC_REQUIRE([gt_LOCALE_JA]) |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
376 AC_REQUIRE([AC_CANONICAL_HOST]) |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
377 AC_CACHE_CHECK([whether mbrtowc has a correct return value], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
378 [gl_cv_func_mbrtowc_retval], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
379 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
380 dnl Initial guess, used when cross-compiling or when no suitable locale |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
381 dnl is present. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
382 changequote(,)dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
383 case "$host_os" in |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
384 # Guess no on HP-UX, Solaris, native Windows. |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
385 hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
386 # Guess yes otherwise. |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
387 *) gl_cv_func_mbrtowc_retval="guessing yes" ;; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
388 esac |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
389 changequote([,])dnl |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
390 if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
391 || { case "$host_os" in mingw*) true;; *) false;; esac; }; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
392 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
393 [AC_LANG_SOURCE([[ |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
394 #include <locale.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
395 #include <string.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
396 /* 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
|
397 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
398 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
|
399 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
400 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
401 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
402 #include <time.h> |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
403 #include <wchar.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
404 int main () |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
405 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
406 int result = 0; |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
407 int found_some_locale = 0; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
408 /* This fails on Solaris. */ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
409 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
410 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
411 char input[] = "B\303\274\303\237er"; /* "Büßer" */ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
412 mbstate_t state; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
413 wchar_t wc; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
414 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
415 memset (&state, '\0', sizeof (mbstate_t)); |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
416 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
417 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
418 input[1] = '\0'; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
419 if (mbrtowc (&wc, input + 2, 5, &state) != 1) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
420 result |= 1; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
421 } |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
422 found_some_locale = 1; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
423 } |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
424 /* This fails on HP-UX 11.11. */ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
425 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
426 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
427 char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
428 mbstate_t state; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
429 wchar_t wc; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
430 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
431 memset (&state, '\0', sizeof (mbstate_t)); |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
432 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
433 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
434 input[1] = '\0'; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
435 if (mbrtowc (&wc, input + 2, 5, &state) != 2) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
436 result |= 2; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
437 } |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
438 found_some_locale = 1; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
439 } |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
440 /* This fails on native Windows. */ |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
441 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
442 { |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
443 char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */ |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
444 mbstate_t state; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
445 wchar_t wc; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
446 |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
447 memset (&state, '\0', sizeof (mbstate_t)); |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
448 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
449 { |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
450 input[3] = '\0'; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
451 if (mbrtowc (&wc, input + 4, 4, &state) != 1) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
452 result |= 4; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
453 } |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
454 found_some_locale = 1; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
455 } |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
456 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
457 { |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
458 char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */ |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
459 mbstate_t state; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
460 wchar_t wc; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
461 |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
462 memset (&state, '\0', sizeof (mbstate_t)); |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
463 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
464 { |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
465 input[3] = '\0'; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
466 if (mbrtowc (&wc, input + 4, 4, &state) != 1) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
467 result |= 8; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
468 } |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
469 found_some_locale = 1; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
470 } |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
471 if (setlocale (LC_ALL, "Chinese_China.936") != NULL) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
472 { |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
473 char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */ |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
474 mbstate_t state; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
475 wchar_t wc; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
476 |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
477 memset (&state, '\0', sizeof (mbstate_t)); |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
478 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2)) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
479 { |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
480 input[3] = '\0'; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
481 if (mbrtowc (&wc, input + 4, 4, &state) != 1) |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
482 result |= 16; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
483 } |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
484 found_some_locale = 1; |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
485 } |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
486 return (found_some_locale ? result : 77); |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
487 }]])], |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
488 [gl_cv_func_mbrtowc_retval=yes], |
14346
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
489 [if test $? != 77; then |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
490 gl_cv_func_mbrtowc_retval=no |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
491 fi |
dceb65f713b5
mbrtowc: Work around native Windows bug.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
492 ], |
11493
fcd8e65744b2
Fix cross-compilation results.
Bruno Haible <bruno@clisp.org>
parents:
11218
diff
changeset
|
493 [:]) |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
494 fi |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
495 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
496 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
497 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
498 dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
499 dnl Result is gl_cv_func_mbrtowc_nul_retval. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
500 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
501 AC_DEFUN([gl_MBRTOWC_NUL_RETVAL], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
502 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
503 AC_REQUIRE([AC_PROG_CC]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
504 AC_REQUIRE([gt_LOCALE_ZH_CN]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
505 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
506 AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
507 [gl_cv_func_mbrtowc_nul_retval], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
508 [ |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
509 dnl Initial guess, used when cross-compiling or when no suitable locale |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
510 dnl is present. |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
511 changequote(,)dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
512 case "$host_os" in |
11218
d3d4cc78595e
Update guessed test results.
Bruno Haible <bruno@clisp.org>
parents:
11217
diff
changeset
|
513 # Guess no on Solaris 8 and 9. |
d3d4cc78595e
Update guessed test results.
Bruno Haible <bruno@clisp.org>
parents:
11217
diff
changeset
|
514 solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;; |
d3d4cc78595e
Update guessed test results.
Bruno Haible <bruno@clisp.org>
parents:
11217
diff
changeset
|
515 # Guess yes otherwise. |
d3d4cc78595e
Update guessed test results.
Bruno Haible <bruno@clisp.org>
parents:
11217
diff
changeset
|
516 *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
517 esac |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
518 changequote([,])dnl |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
519 if test $LOCALE_ZH_CN != none; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
520 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
521 [AC_LANG_SOURCE([[ |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
522 #include <locale.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
523 #include <string.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
524 /* 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
|
525 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
526 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
|
527 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
528 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
529 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
530 #include <time.h> |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
531 #include <wchar.h> |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
532 int main () |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
533 { |
11218
d3d4cc78595e
Update guessed test results.
Bruno Haible <bruno@clisp.org>
parents:
11217
diff
changeset
|
534 /* This fails on Solaris 8 and 9. */ |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
535 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
536 { |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
537 mbstate_t state; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
538 wchar_t wc; |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
539 |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
540 memset (&state, '\0', sizeof (mbstate_t)); |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
541 if (mbrtowc (&wc, "", 1, &state) != 0) |
18530
4cb1f97031ad
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18292
diff
changeset
|
542 return 2; |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
543 } |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
544 return 0; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13485
diff
changeset
|
545 }]])], |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
546 [gl_cv_func_mbrtowc_nul_retval=yes], |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
547 [gl_cv_func_mbrtowc_nul_retval=no], |
11493
fcd8e65744b2
Fix cross-compilation results.
Bruno Haible <bruno@clisp.org>
parents:
11218
diff
changeset
|
548 [:]) |
10924
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
549 fi |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
550 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
551 ]) |
6f547b3710c7
Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
10906
diff
changeset
|
552 |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
553 dnl Test whether mbrtowc returns the correct value on empty input. |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
554 |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
555 AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT], |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
556 [ |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
557 AC_REQUIRE([AC_PROG_CC]) |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
558 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
559 AC_CACHE_CHECK([whether mbrtowc works on empty input], |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
560 [gl_cv_func_mbrtowc_empty_input], |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
561 [ |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
562 dnl Initial guess, used when cross-compiling or when no suitable locale |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
563 dnl is present. |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
564 changequote(,)dnl |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
565 case "$host_os" in |
19479
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
566 # Guess no on AIX and glibc systems. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
567 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
568 # Guess yes on native Windows. |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
569 mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; |
4bc5b8cefed7
Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents:
18993
diff
changeset
|
570 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
571 esac |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
572 changequote([,])dnl |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
573 AC_RUN_IFELSE( |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
574 [AC_LANG_SOURCE([[ |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
575 #include <wchar.h> |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
576 static wchar_t wc; |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
577 static mbstate_t mbs; |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
578 int |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
579 main (void) |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
580 { |
18185
aac4a75f4676
maint: fix operator precedence in mbrtowc test
Daiki Ueno <ueno@gnu.org>
parents:
18152
diff
changeset
|
581 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
582 }]])], |
18152
1997ee52dcf6
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18109
diff
changeset
|
583 [gl_cv_func_mbrtowc_empty_input=yes], |
17660
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
584 [gl_cv_func_mbrtowc_empty_input=no], |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
585 [:]) |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
586 ]) |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
587 ]) |
ea9dc06bfca8
mbrlen, mbrtowc: fix bug with empty input
Paul Eggert <eggert@cs.ucla.edu>
parents:
17576
diff
changeset
|
588 |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
589 dnl Test whether mbrtowc reports encoding errors in the C locale. |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
590 dnl Although POSIX was never intended to allow this, the GNU C Library |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
591 dnl and other implementations do it. See: |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
592 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
593 |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
594 AC_DEFUN([gl_MBRTOWC_C_LOCALE], |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
595 [ |
18993
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
596 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
597 AC_CACHE_CHECK([whether the C locale is free of encoding errors], |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
598 [gl_cv_C_locale_sans_EILSEQ], |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
599 [ |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
600 dnl Initial guess, used when cross-compiling or when no suitable locale |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
601 dnl is present. |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
602 gl_cv_C_locale_sans_EILSEQ="guessing no" |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
603 |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
604 AC_RUN_IFELSE( |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
605 [AC_LANG_PROGRAM( |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
606 [[#include <limits.h> |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
607 #include <locale.h> |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
608 #include <wchar.h> |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
609 ]], [[ |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
610 int i; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
611 char *locale = setlocale (LC_ALL, "C"); |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
612 if (! locale) |
18530
4cb1f97031ad
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18292
diff
changeset
|
613 return 2; |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
614 for (i = CHAR_MIN; i <= CHAR_MAX; i++) |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
615 { |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
616 char c = i; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
617 wchar_t wc; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
618 mbstate_t mbs = { 0, }; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
619 size_t ss = mbrtowc (&wc, &c, 1, &mbs); |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
620 if (1 < ss) |
18530
4cb1f97031ad
maint: use a more standard return from mbrtowc test
Pádraig Brady <P@draigBrady.com>
parents:
18292
diff
changeset
|
621 return 3; |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
622 } |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
623 return 0; |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
624 ]])], |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
625 [gl_cv_C_locale_sans_EILSEQ=yes], |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
626 [gl_cv_C_locale_sans_EILSEQ=no], |
18993
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
627 [case "$host_os" in |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
628 # Guess yes on native Windows. |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
629 mingw*) gl_cv_C_locale_sans_EILSEQ="guessing yes" ;; |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
630 esac |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
631 ]) |
a75cfc731331
Improve cross-compilation guesses for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
18990
diff
changeset
|
632 ]) |
18292
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
633 ]) |
24fde31e764d
mbrtowc: work around glibc bug#19932
Paul Eggert <eggert@penguin.cs.ucla.edu>
parents:
18189
diff
changeset
|
634 |
10906 | 635 # Prerequisites of lib/mbrtowc.c. |
636 AC_DEFUN([gl_PREREQ_MBRTOWC], [ | |
39704
46aa87a2631e
mbrtowc, wcwidth: Fix MT-safety bug (regression from 2018-06-23).
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
637 AC_REQUIRE([AC_C_INLINE]) |
10906 | 638 : |
639 ]) | |
640 | |
641 | |
3167
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
642 dnl From Paul Eggert |
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
643 |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
644 dnl This is an override of an autoconf macro. |
4108
c1d472db5c30
An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents:
3882
diff
changeset
|
645 |
10897
45e1c3577b49
Rename gl_FUNC_MBRTOWC to AC_FUNC_MBRTOWC.
Bruno Haible <bruno@clisp.org>
parents:
5964
diff
changeset
|
646 AC_DEFUN([AC_FUNC_MBRTOWC], |
3167
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
647 [ |
5964
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
648 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. |
3171
702f81769818
(jm_FUNC_MBRTOWC): Adapt to use AC_CACHE_CHECK etc., rather than AC_CACHE_VAL.
Jim Meyering <jim@meyering.net>
parents:
3167
diff
changeset
|
649 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], |
18990
4e69302a47a0
More systematic m4 quoting and indentation.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
650 [gl_cv_func_mbrtowc], |
5964
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
651 [AC_LINK_IFELSE( |
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
652 [AC_LANG_PROGRAM( |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
653 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
654 included before <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
655 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
656 must be included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
657 #include <stddef.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
658 #include <stdio.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
659 #include <time.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
660 #include <wchar.h>]], |
5964
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
661 [[wchar_t wc; |
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
662 char const s[] = ""; |
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
663 size_t n = 1; |
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
664 mbstate_t state; |
111f78a51516
Avoid false positive on mingw.
Bruno Haible <bruno@clisp.org>
parents:
5585
diff
changeset
|
665 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], |
18990
4e69302a47a0
More systematic m4 quoting and indentation.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
666 [gl_cv_func_mbrtowc=yes], |
4e69302a47a0
More systematic m4 quoting and indentation.
Bruno Haible <bruno@clisp.org>
parents:
18626
diff
changeset
|
667 [gl_cv_func_mbrtowc=no])]) |
5018 | 668 if test $gl_cv_func_mbrtowc = yes; then |
11007
f6cba5a556ce
many *.m4 files: improve m4 quoting
Jim Meyering <meyering@redhat.com>
parents:
10957
diff
changeset
|
669 AC_DEFINE([HAVE_MBRTOWC], [1], |
3167
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
670 [Define to 1 if mbrtowc and mbstate_t are properly declared.]) |
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
671 fi |
9e312d4334b8
New file, defining jm_FUNC_MBRTOWC.
Jim Meyering <jim@meyering.net>
parents:
diff
changeset
|
672 ]) |