1 | # btowc.m4 serial 10
|
---|
2 | dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
---|
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_BTOWC],
|
---|
8 | [
|
---|
9 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
---|
10 |
|
---|
11 | dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
|
---|
12 | dnl program below may lead to an endless loop. See
|
---|
13 | dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
|
---|
14 | AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
|
---|
15 |
|
---|
16 | AC_CHECK_FUNCS_ONCE([btowc])
|
---|
17 | if test $ac_cv_func_btowc = no; then
|
---|
18 | HAVE_BTOWC=0
|
---|
19 | else
|
---|
20 |
|
---|
21 | AC_REQUIRE([AC_PROG_CC])
|
---|
22 | AC_REQUIRE([gt_LOCALE_FR])
|
---|
23 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
---|
24 |
|
---|
25 | dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0.
|
---|
26 | AC_CACHE_CHECK([whether btowc(0) is correct],
|
---|
27 | [gl_cv_func_btowc_nul],
|
---|
28 | [
|
---|
29 | AC_RUN_IFELSE(
|
---|
30 | [AC_LANG_SOURCE([[
|
---|
31 | #include <string.h>
|
---|
32 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
---|
33 | <wchar.h>.
|
---|
34 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
---|
35 | included before <wchar.h>. */
|
---|
36 | #include <stddef.h>
|
---|
37 | #include <stdio.h>
|
---|
38 | #include <time.h>
|
---|
39 | #include <wchar.h>
|
---|
40 | int main ()
|
---|
41 | {
|
---|
42 | if (btowc ('\0') != 0)
|
---|
43 | return 1;
|
---|
44 | return 0;
|
---|
45 | }]])],
|
---|
46 | [gl_cv_func_btowc_nul=yes],
|
---|
47 | [gl_cv_func_btowc_nul=no],
|
---|
48 | [
|
---|
49 | changequote(,)dnl
|
---|
50 | case "$host_os" in
|
---|
51 | # Guess no on Cygwin.
|
---|
52 | cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
|
---|
53 | # Guess yes otherwise.
|
---|
54 | *) gl_cv_func_btowc_nul="guessing yes" ;;
|
---|
55 | esac
|
---|
56 | changequote([,])dnl
|
---|
57 | ])
|
---|
58 | ])
|
---|
59 |
|
---|
60 | dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
|
---|
61 | AC_CACHE_CHECK([whether btowc(EOF) is correct],
|
---|
62 | [gl_cv_func_btowc_eof],
|
---|
63 | [
|
---|
64 | dnl Initial guess, used when cross-compiling or when no suitable locale
|
---|
65 | dnl is present.
|
---|
66 | changequote(,)dnl
|
---|
67 | case "$host_os" in
|
---|
68 | # Guess no on IRIX.
|
---|
69 | irix*) gl_cv_func_btowc_eof="guessing no" ;;
|
---|
70 | # Guess yes otherwise.
|
---|
71 | *) gl_cv_func_btowc_eof="guessing yes" ;;
|
---|
72 | esac
|
---|
73 | changequote([,])dnl
|
---|
74 | if test $LOCALE_FR != none; then
|
---|
75 | AC_RUN_IFELSE(
|
---|
76 | [AC_LANG_SOURCE([[
|
---|
77 | #include <locale.h>
|
---|
78 | #include <string.h>
|
---|
79 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
---|
80 | <wchar.h>.
|
---|
81 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
---|
82 | included before <wchar.h>. */
|
---|
83 | #include <stddef.h>
|
---|
84 | #include <stdio.h>
|
---|
85 | #include <time.h>
|
---|
86 | #include <wchar.h>
|
---|
87 | int main ()
|
---|
88 | {
|
---|
89 | if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
|
---|
90 | {
|
---|
91 | if (btowc (EOF) != WEOF)
|
---|
92 | return 1;
|
---|
93 | }
|
---|
94 | return 0;
|
---|
95 | }]])],
|
---|
96 | [gl_cv_func_btowc_eof=yes],
|
---|
97 | [gl_cv_func_btowc_eof=no],
|
---|
98 | [:])
|
---|
99 | fi
|
---|
100 | ])
|
---|
101 |
|
---|
102 | case "$gl_cv_func_btowc_nul" in
|
---|
103 | *yes) ;;
|
---|
104 | *) REPLACE_BTOWC=1 ;;
|
---|
105 | esac
|
---|
106 | case "$gl_cv_func_btowc_eof" in
|
---|
107 | *yes) ;;
|
---|
108 | *) REPLACE_BTOWC=1 ;;
|
---|
109 | esac
|
---|
110 | fi
|
---|
111 | ])
|
---|
112 |
|
---|
113 | # Prerequisites of lib/btowc.c.
|
---|
114 | AC_DEFUN([gl_PREREQ_BTOWC], [
|
---|
115 | :
|
---|
116 | ])
|
---|