1 /*
2  *      cook - file construction tool
3  *      Copyright (C) 1997-1999, 2002, 2006, 2007 Peter Miller;
4  *      All rights reserved.
5  *
6  *      This program is free software; you can redistribute it and/or modify
7  *      it under the terms of the GNU General Public License as published by
8  *      the Free Software Foundation; either version 3 of the License, or
9  *      (at your option) any later version.
10  *
11  *      This program is distributed in the hope that it will be useful,
12  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *      GNU General Public License for more details.
15  *
16  *      You should have received a copy of the GNU General Public License
17  *      along with this program. If not, see
18  *      <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef COMMON_AC_WCHAR_H
22 #define COMMON_AC_WCHAR_H
23 
24 /*
25  * From the ``believe it or not'' category: The Dec Alpha OSF/1
26  * <wchar.h> includes <time.h>, but we need to make sure our own
27  * <common/ac/time.h> is invoked first.
28  */
29 #ifdef __alpha___
30 #include <common/ac/time.h>
31 #endif
32 
33 /*
34  * Cygwin's wchar.h has a missing size_t dependency, so include that first.
35  */
36 #include <common/ac/stddef.h>
37 
38 #ifdef HAVE_WCHAR_H
39 #include <wchar.h>
40 #else
41 
42 #include <common/ac/stddef.h>
43 #include <common/main.h>
44 typedef int mbstate_t;
45 #ifndef WEOF
46 #define WEOF (wchar_t)(-1);
47 #endif
48 int mbsinit(const mbstate_t *);
49 size_t wcslen(const wchar_t *);
50 size_t mbrlen(const char *, size_t, mbstate_t *);
51 size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
52 size_t wcrtomb(char *, wchar_t, mbstate_t *);
53 size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
54 size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
55 
56 #endif
57 
58 
59 /*
60  * HAVE_ISWPRINT is only set if (a) there is a have_iswprint function,
61  * and (b) it works for ascii.  It is assumed that if iswprint is absent
62  * or brain-dead, then so are the rest.
63  *
64  * This code copes with the case where (a) it exists, (b) it is broken,
65  * and (c) it is defined in <wchar.h>, of all places!
66  */
67 #ifndef HAVE_ISWPRINT
68 
69 #ifdef iswprint
70 #undef iswprint
71 #endif
72 
73 #ifdef iswspace
74 #undef iswspace
75 #endif
76 
77 #ifdef iswpunct
78 #undef iswpunct
79 #endif
80 
81 #ifdef iswupper
82 #undef iswupper
83 #endif
84 
85 #ifdef iswlower
86 #undef iswlower
87 #endif
88 
89 #ifdef iswdigit
90 #undef iswdigit
91 #endif
92 
93 #ifdef iswalnum
94 #undef iswalnum
95 #endif
96 
97 #ifdef towupper
98 #undef towupper
99 #endif
100 
101 #ifdef towlower
102 #undef towlower
103 #endif
104 
105 #endif /* !HAVE_ISWPRINT */
106 
107 /*
108  * The ANSI C standard states that wint_t symbol shall be defined by
109  * <wchar.h> and <wctype.h>.  The GNU people also define it in <stddef.h>,
110  * but this is incorrect.
111  */
112 #ifndef HAVE_WINT_T
113 #define HAVE_WINT_T
114 typedef wchar_t wint_t;
115 #endif
116 
117 #endif /* COMMON_AC_WCHAR_H */
118