Mercurial > hg > octave-jordi > gnulib-hg
annotate m4/wcrtomb.m4 @ 17921:58c1b50299a6
getopt: give accurate ambiguity diagnostic on mem exhaustion
* lib/getopt.c (_getopt_internal_r): The previous commit broke
out the loop too early, which could give a false indication
of ambiguous options under memory exhaustion.
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Wed, 18 Feb 2015 22:37:31 +0000 |
parents | ab58d4870664 |
children |
rev | line source |
---|---|
15483
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
1 # wcrtomb.m4 serial 11 |
17848 | 2 dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. |
10936 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 AC_DEFUN([gl_FUNC_WCRTOMB], | |
8 [ | |
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | |
10 | |
11 AC_REQUIRE([AC_TYPE_MBSTATE_T]) | |
11527
4fe203c3f828
Replace wcrtomb, wcsrtombs, wcsnrtombs if mbstate_t has to be replaced.
Bruno Haible <bruno@clisp.org>
parents:
11493
diff
changeset
|
12 gl_MBSTATE_T_BROKEN |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
13 |
10936 | 14 AC_CHECK_FUNCS_ONCE([wcrtomb]) |
15 if test $ac_cv_func_wcrtomb = no; then | |
16 HAVE_WCRTOMB=0 | |
15483
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
17 AC_CHECK_DECLS([wcrtomb],,, [[ |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
18 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
19 <wchar.h>. |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
21 included before <wchar.h>. */ |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
22 #include <stddef.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
23 #include <stdio.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
24 #include <time.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
25 #include <wchar.h> |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
26 ]]) |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
27 if test $ac_cv_have_decl_wcrtomb = yes; then |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
29 dnl it does not have the function. Avoid a collision with gnulib's |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
30 dnl replacement. |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
31 REPLACE_WCRTOMB=1 |
1aca03539329
Work around declaration collisions on Minix.
Bruno Haible <bruno@clisp.org>
parents:
15140
diff
changeset
|
32 fi |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
33 else |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
34 if test $REPLACE_MBSTATE_T = 1; then |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 REPLACE_WCRTOMB=1 |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 else |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
38 dnl returns 0 instead of 1. |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
39 AC_REQUIRE([AC_PROG_CC]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
40 AC_REQUIRE([gt_LOCALE_FR]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
41 AC_REQUIRE([gt_LOCALE_FR_UTF8]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
42 AC_REQUIRE([gt_LOCALE_JA]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
43 AC_REQUIRE([gt_LOCALE_ZH_CN]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
44 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
45 AC_CACHE_CHECK([whether wcrtomb return value is correct], |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
46 [gl_cv_func_wcrtomb_retval], |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
47 [ |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
48 dnl Initial guess, used when cross-compiling or when no suitable locale |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
49 dnl is present. |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
50 changequote(,)dnl |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
51 case "$host_os" in |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
52 # Guess no on AIX 4, OSF/1 and Solaris. |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
53 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
54 # Guess yes otherwise. |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
55 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
56 esac |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
57 changequote([,])dnl |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
59 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
60 [AC_LANG_SOURCE([[ |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
61 #include <locale.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
62 #include <string.h> |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
63 /* 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
|
64 <wchar.h>. |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
65 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
|
66 included before <wchar.h>. */ |
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
67 #include <stddef.h> |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
68 #include <stdio.h> |
14020
318a4063e921
Ensure all prerequisites of <wchar.h> are included.
Bruno Haible <bruno@clisp.org>
parents:
13918
diff
changeset
|
69 #include <time.h> |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
70 #include <wchar.h> |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
71 int main () |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
72 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
73 int result = 0; |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
74 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
75 { |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
76 if (wcrtomb (NULL, 0, NULL) != 1) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
77 result |= 1; |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
78 } |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
79 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
80 { |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
81 if (wcrtomb (NULL, 0, NULL) != 1) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
82 result |= 2; |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
83 } |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
85 { |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
86 if (wcrtomb (NULL, 0, NULL) != 1) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
87 result |= 4; |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
88 } |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
89 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
90 { |
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
91 if (wcrtomb (NULL, 0, NULL) != 1) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
92 result |= 8; |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
93 } |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
94 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13158
diff
changeset
|
95 }]])], |
13158
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
96 [gl_cv_func_wcrtomb_retval=yes], |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
97 [gl_cv_func_wcrtomb_retval=no], |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
98 [:]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
99 fi |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
100 ]) |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
101 case "$gl_cv_func_wcrtomb_retval" in |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
102 *yes) ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
103 *) REPLACE_WCRTOMB=1 ;; |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
104 esac |
6c2a74cfe75b
mbsinit, mbrtowc, wcrtomb: Improve idioms.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
105 fi |
10939
4ee0271437dd
Work around a wcrtomb() bug on Solaris 10 and OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents:
10936
diff
changeset
|
106 fi |
10936 | 107 ]) |
108 | |
109 # Prerequisites of lib/wcrtomb.c. | |
110 AC_DEFUN([gl_PREREQ_WCRTOMB], [ | |
111 : | |
112 ]) |