1 /* ------------------------------------------------------------------
2 * The Goldware Library
3 * Copyright (C) 1999 Alexander S. Aganichev
4 * ------------------------------------------------------------------
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307, USA
19 * ------------------------------------------------------------------
20 * $Id: gctype.h,v 1.23 2010/04/29 22:28:17 stas_degteff Exp $
21 * ------------------------------------------------------------------
22 * Portable NLS functions for ctype.
23 * --------------------------------------------------------------- */
24
25 #ifndef __gctype_h
26 #define __gctype_h
27
28
29 /* --------------------------------------------------------------- */
30
31 #include <gcmpall.h>
32
33
34 /* --------------------------------------------------------------- */
35
36 #ifdef __BORLANDC__
37 #define __USELOCALES__
38 #elif defined(__EMX__)
39 #define _CTYPE_FUN
40 #endif
41 #include <ctype.h>
42 #if defined(__EMX__)
43 //old EMX 0.9d code
44 //#include <sys/nls.h>
45 //#define g_tolower(c) _nls_tolower((uint8_t)(c))
46 //#define g_toupper(c) _nls_toupper((uint8_t)(c))
47 //old EMX 0.9d code
48 #define g_tolower(c) tolower(c)
49 #define g_toupper(c) toupper(c)
50 #elif defined(__WIN32__)
51 #ifdef __cplusplus
52 extern "C" {
53 extern char tl[256], tu[256];
g_tolower(int c)54 __inline__ int g_tolower(int c) { return tl[c]; }
g_toupper(int c)55 __inline__ int g_toupper(int c) { return tu[c]; }
56 }
57 #else
58 extern char tl[256], tu[256];
59 #define g_tolower(c) tl[(int)(uint8_t)(c)]
60 #define g_toupper(c) tu[(int)(uint8_t)(c)]
61 #endif
62 #else
63 #define g_tolower(c) tolower(c)
64 #define g_toupper(c) toupper(c)
65 #endif
66
67
68 /* --------------------------------------------------------------- */
69
70 /* NLS chars detected by converting to lower or upper case and in case
71 * they don't match they treated as characters
72 */
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77
78 #if defined(__WIN32__)
79 int g_islower(int c);
80 int g_isupper(int c);
81 int g_isalpha(int c);
82 #else
83 #define g_islower(c) islower(c)
84 #define g_isupper(c) isupper(c)
85 #define g_isalpha(c) isalpha(c)
86 #endif
87
88 int isxalnum(int c);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #ifdef __BEOS__
95 /* sz: there are some problems under BeOS with that function - symbols
96 * from second half of ASCII table are assumed as control ones ...
97 * This is a real disaster for cyrillic users ...
98 * It's also not possible to use setlocale() to change it's behaviour. =-(
99 */
100 # undef iscntrl
101 # define iscntrl(c) ((c < 0x7f) ? __isctype((c), _IScntrl) : 0)
102 #endif /* __BEOS__ */
103
104 /* --------------------------------------------------------------- */
105
106 #endif
107
108 /* --------------------------------------------------------------- */
109