Update spec to require automake >= 1.13
[platform/upstream/gawk.git] / mbsupport.h
1 /*
2  * mbsupport.h --- Localize determination of whether we have multibyte stuff.
3  */
4
5 /* 
6  * Copyright (C) 2004, 2005, 2011, 2012 the Free Software Foundation, Inc.
7  * 
8  * This file is part of GAWK, the GNU implementation of the
9  * AWK Programming Language.
10  * 
11  * GAWK is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  * 
16  * GAWK is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
24  */
25
26 /*
27  * This file is needed because we test for i18n support in 3 different
28  * places, and we want a consistent definition in all of them.  Following
29  * the ``Don't Repeat Yourself'' principle from "The Pragmatic Programmer",
30  * we centralize the tests here.
31  *
32  * This test is the union of all the current tests.
33  */
34
35 #ifdef HAVE_STDLIB_H
36 #include <stdlib.h>
37 #endif
38
39 #ifndef NO_MBSUPPORT
40
41 #if    defined(HAVE_ISWCTYPE) \
42     && defined(HAVE_LOCALE_H) \
43     && (defined(HAVE_BTOWC) || defined(ZOS_USS)) \
44     && defined(HAVE_MBRLEN) \
45     && defined(HAVE_MBRTOWC) \
46     && defined(HAVE_WCHAR_H) \
47     && defined(HAVE_WCRTOMB) \
48     && defined(HAVE_WCSCOLL) \
49     && defined(HAVE_WCTYPE) \
50     && defined(HAVE_WCTYPE_H) \
51     && defined(HAVE_WCTYPE_T) \
52     && defined(HAVE_WINT_T) \
53     && defined(HAVE_ISWLOWER) \
54     && defined(HAVE_ISWUPPER) \
55     && defined(HAVE_TOWLOWER) \
56     && defined(HAVE_TOWUPPER) \
57     && (defined(HAVE_STDLIB_H) && defined(MB_CUR_MAX)) \
58 /* We can handle multibyte strings.  */
59 # define MBS_SUPPORT 1
60 #else
61 # define MBS_SUPPORT 0
62 #endif
63
64 #else /* NO_MBSUPPORT is defined */
65 # define MBS_SUPPORT 0
66 #endif
67
68 #if ! MBS_SUPPORT
69 # undef MB_CUR_MAX
70 # define MB_CUR_MAX 1
71
72 /* All this glop is for dfa.c. Bleah. */
73
74 #ifndef __DJGPP__
75 #define wchar_t         char
76 #endif
77
78 #define wctype_t        int
79 #define wint_t          int
80 #define mbstate_t       int
81 #define WEOF            EOF
82 #define towupper        toupper
83 #define towlower        tolower
84 #ifndef __DJGPP__
85 #define btowc(x)        ((int)x)
86 #endif
87 #define iswalnum        isalnum
88 #define iswalpha        isalpha
89 #define iswupper        isupper
90 #if defined(ZOS_USS)
91 #undef towupper
92 #undef towlower
93 #undef btowc
94 #undef iswalnum
95 #undef iswalpha
96 #undef iswupper
97 #undef wctype
98 #undef iswctype
99 #undef wcscoll
100 #endif
101
102 extern wctype_t wctype(const char *name);
103 extern int iswctype(wint_t wc, wctype_t desc);
104 extern int wcscoll(const wchar_t *ws1, const wchar_t *ws2);
105 #endif