gdb: GC old versions
[dragonfly.git] / contrib / gdb-7 / gdb / gdb_wchar.h
1 /* Wide characters for gdb
2    Copyright (C) 2009 Free Software Foundation, Inc.
3
4    This file is part of GDB.
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 <http://www.gnu.org/licenses/>.  */
18
19 #ifndef GDB_WCHAR_H
20 #define GDB_WCHAR_H
21
22 /* We handle three different modes here.
23    
24    Capable systems have the full suite: wchar_t support and iconv
25    (perhaps via GNU libiconv).  On these machines, full functionality
26    is available.
27    
28    DJGPP is known to have libiconv but not wchar_t support.  On
29    systems like this, we use the narrow character functions.  The full
30    functionality is available to the user, but many characters (those
31    outside the narrow range) will be displayed as escapes.
32    
33    Finally, some systems do not have iconv.  Here we provide a phony
34    iconv which only handles a single character set, and we provide
35    wrappers for the wchar_t functionality we use.  */
36
37
38 #define INTERMEDIATE_ENCODING "wchar_t"
39
40 #if defined (HAVE_ICONV)
41 #include <iconv.h>
42 #else
43 /* This define is used elsewhere so we don't need to duplicate the
44    same checking logic in multiple places.  */
45 #define PHONY_ICONV
46 #endif
47
48 /* We use "btowc" as a sentinel to detect functioning wchar_t
49    support.  */
50 #if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC)
51
52 #include <wchar.h>
53 #include <wctype.h>
54
55 typedef wchar_t gdb_wchar_t;
56 typedef wint_t gdb_wint_t;
57
58 #define gdb_wcslen wcslen
59 #define gdb_iswprint iswprint
60 #define gdb_iswdigit iswdigit
61 #define gdb_btowc btowc
62 #define gdb_WEOF WEOF
63
64 #define LCST(X) L ## X
65
66 #else
67
68 typedef char gdb_wchar_t;
69 typedef int gdb_wint_t;
70
71 #define gdb_wcslen strlen
72 #define gdb_iswprint isprint
73 #define gdb_iswdigit isdigit
74 #define gdb_btowc /* empty */
75 #define gdb_WEOF EOF
76
77 #define LCST(X) X
78
79 /* If we are using the narrow character set, we want to use the host
80    narrow encoding as our intermediate encoding.  However, if we are
81    also providing a phony iconv, we might as well just stick with
82    "wchar_t".  */
83 #ifndef PHONY_ICONV
84 #undef INTERMEDIATE_ENCODING
85 #define INTERMEDIATE_ENCODING host_charset ()
86 #endif
87
88 #endif
89
90 #endif /* GDB_WCHAR_H */