3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
20 #ifndef _STLP_C_LOCALE_H
21 #define _STLP_C_LOCALE_H
24 * Implementation dependent definitions.
25 * Beware: This header is not a purely internal header, it is also included
26 * from the outside world when building the STLport library. So this header
27 * should not reference internal headers (stlport/stl/_*.h) directly.
30 # if defined (ROOT_65) /* IRIX 6.5.x */
32 # include <standards.h>
35 # else /* IRIX pre-6.5 */
37 # include <standards.h>
38 # if !defined(_SIZE_T) && !defined(_SIZE_T_)
40 # if (_MIPS_SZLONG == 32)
41 typedef unsigned int size_t;
43 # if (_MIPS_SZLONG == 64)
44 typedef unsigned long size_t;
47 # if !defined (_WCHAR_T)
49 # if (_MIPS_SZLONG == 32)
52 # if (_MIPS_SZLONG == 64)
53 typedef __int32_t wchar_t;
55 # endif /* _WCHAR_T */
56 # if !defined (_WINT_T)
58 # if (_MIPS_SZLONG == 32)
61 # if (_MIPS_SZLONG == 64)
62 typedef __int32_t wint_t;
65 # if !defined (_MBSTATE_T)
67 /* _MSC_VER check is here for historical reason and seems wrong as it is the macro defined
68 * by Microsoft compilers to give their version and we are currently in a SGI platform scope.
69 * However _MSC_VER might also be a SGI compiler macro so we keep it this way.*/
70 # if defined (_MSC_VER)
71 typedef int mbstate_t;
73 typedef char mbstate_t;
75 # endif /* _MBSTATE_T */
88 * Opaque types, implementation (if there is one) depends
89 * on platform locale API.
92 struct _Locale_numeric;
94 struct _Locale_collate;
95 struct _Locale_monetary;
96 struct _Locale_messages;
97 struct _Locale_name_hint;
104 * For narrow characters, we expose the lookup table interface.
107 /* Internal bitmask macros, os-specific. */
109 #if defined (__sgi) /* IRIX */
111 # define _Locale_S 0x00000008 /* Spacing character */
112 # define _Locale_A 0x00004000 /* Alphabetical characters only */
113 # define _Locale_B 0x00000040 /* Obsolete: was space char only */
114 # define _Locale_PR 0x00008000 /* Printable characters only */
115 # define _Locale_G 0x40000000 /* Graphic characters only */
116 # define _Locale_BL 0x80000000 /* The blank character class */
118 /* Public bitmask macros, must be defined for every OS. These values, of
119 * course, are specific to IRIX. */
121 # define _Locale_CNTRL 0x00000020 /* Control character */
122 # define _Locale_UPPER 0x00000001 /* Upper case */
123 # define _Locale_LOWER 0x00000002 /* Lower case */
124 # define _Locale_DIGIT 0x00000004 /* Numeral (digit) */
125 # define _Locale_XDIGIT 0x00000080 /* heXadecimal digit */
126 # define _Locale_PUNCT 0x00000010 /* Punctuation */
127 # define _Locale_SPACE (_Locale_S | _Locale_BL)
128 # define _Locale_PRINT (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
129 _Locale_DIGIT | _Locale_A | _Locale_XDIGIT | \
131 # define _Locale_ALPHA _Locale_A
134 * All of these except for graph and blank are from the C standard;
135 * graph and blank are XPG4. (graph in XPG4 doesn't mean quite the
136 * same thing as graph in the C++ library)
142 #if defined (__Lynx__)
143 /* azov: On Lynx isalpha defined as (_U | _L), which gives us a mask
144 * unusable in ctype_table. So we have to redefine it and use hard-coded
145 * numbers (to avoid potential clashes if system headers change).
147 * P.S. Actually, I see no reason in using platform-specific masks -
148 * having just one set of masks for all platforms should work just as
149 * well - we only use them internally and they don't have to be equal
150 * to whatever defined in local ctype.h
153 # define _Locale_CNTRL 040 /* _C, Control character */
154 # define _Locale_UPPER 01 /* _U, Upper case */
155 # define _Locale_LOWER 02 /* _L, Lower case */
156 # define _Locale_DIGIT 04 /* _N, Numeral (digit) */
157 # define _Locale_XDIGIT 0200 /* _X, heXadecimal digit */
158 # define _Locale_PUNCT 020 /* _P, Punctuation */
159 # define _Locale_SPACE 010 /* _S, Spacing */
160 # define _Locale_ALPHA 040000 /* none, Alphanumerical */
161 # define _Locale_PRINT (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
162 _Locale_DIGIT | _Locale_ALPHA | _Locale_XDIGIT |\
163 _Locale_SPACE ) /* Printable */
164 #endif /* __Lynx__ */
166 #if defined (__GNUC__) || defined (__BORLANDC__) || defined (__COMO__)
168 # if defined (__CYGWIN__)
170 # define _Locale_CNTRL 040
171 # define _Locale_UPPER 02
172 # define _Locale_LOWER 01
173 # define _Locale_DIGIT 04
174 # define _Locale_XDIGIT ( 0100 | _Locale_DIGIT )
175 # define _Locale_PUNCT 020
176 # define _Locale_SPACE 010
177 # define _Locale_ALPHA 0200
178 # define _Locale_PRINT (_Locale_ALPHA | _Locale_DIGIT | _Locale_PUNCT | 0400 )
180 # elif defined (__FreeBSD__) || ( defined (__APPLE__) && defined (__GNUC__) && (__GNUC__ > 3) )
182 # define _Locale_CNTRL _CTYPE_C
183 # define _Locale_UPPER _CTYPE_U
184 # define _Locale_LOWER _CTYPE_L
185 # define _Locale_DIGIT _CTYPE_D
186 # define _Locale_XDIGIT _CTYPE_X
187 # define _Locale_PUNCT _CTYPE_P
188 # define _Locale_SPACE _CTYPE_S
189 # define _Locale_PRINT _CTYPE_R
190 # define _Locale_ALPHA _CTYPE_A
192 # elif defined (__NetBSD__) || defined (__OpenBSD__) || defined (__amigaos__)
194 # define _Locale_CNTRL _C
195 # define _Locale_UPPER _U
196 # define _Locale_LOWER _L
197 # define _Locale_DIGIT _N
198 # define _Locale_XDIGIT (_N|_X)
199 # define _Locale_PUNCT _P
200 # define _Locale_SPACE _S
201 # define _Locale_PRINT (_P|_U|_L|_N|_B)
202 # define _Locale_ALPHA (_U|_L)
203 # elif defined (__EMX__) /* OS/2 with emx runtime */
204 # define _Locale_CNTRL _CNTRL
205 # define _Locale_UPPER _UPPER
206 # define _Locale_LOWER _LOWER
207 # define _Locale_DIGIT _DIGIT
208 # define _Locale_XDIGIT _XDIGIT
209 # define _Locale_PUNCT _PUNCT
210 # define _Locale_SPACE _SPACE
211 # define _Locale_PRINT _PRINT
212 # define _Locale_ALPHA (_UPPER|_LOWER)
214 # elif defined (_STLP_USE_GLIBC) /* linux, using the gnu compiler */
216 /* This section uses macros defined in the gnu libc ctype.h header */
218 # define _Locale_CNTRL _IScntrl
219 # define _Locale_UPPER _ISupper
220 # define _Locale_LOWER _ISlower
221 # define _Locale_DIGIT _ISdigit
222 # define _Locale_XDIGIT _ISxdigit
223 # define _Locale_PUNCT _ISpunct
224 # define _Locale_SPACE _ISspace
225 # define _Locale_PRINT _ISprint
226 # define _Locale_ALPHA _ISalpha
232 #if (defined (__sun) && defined (__SVR4)) || \
233 (defined (__digital__) && defined (__unix__)) || \
235 /* fbp : condition from AT&T code*/
236 # if !(defined (__XPG4_CHAR_CLASS__) || defined (_XPG4_2) || \
237 (defined (_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4))) && ! defined (_ISCNTRL)
238 /* fbp : on 2.5.1, the defines are different ;( */
239 /* # if ( defined (__sun) && defined (__SVR4) && ! defined (_ISCNTRL) ) */
244 # define _ISXDIGIT _X
247 # define _ISPRINT (_P | _U | _L | _N | _B)
248 # define _ISALPHA (_U | _L)
251 # define _Locale_CNTRL _ISCNTRL
252 # define _Locale_UPPER _ISUPPER
253 # define _Locale_LOWER _ISLOWER
254 # define _Locale_DIGIT _ISDIGIT
255 # define _Locale_XDIGIT _ISXDIGIT
256 # define _Locale_PUNCT _ISPUNCT
257 # define _Locale_SPACE _ISSPACE
258 # define _Locale_PRINT _ISPRINT
259 # define _Locale_ALPHA _ISALPHA
260 #elif defined (__MWERKS__) && defined (N_PLAT_NLM)
261 # define _Locale_CNTRL _CNTRL_
262 # define _Locale_UPPER _UPPER_
263 # define _Locale_LOWER _LOWER_
264 # define _Locale_DIGIT _DIGIT_
265 # define _Locale_XDIGIT _XDIGIT_
266 # define _Locale_PUNCT _PUNCT_
267 # define _Locale_SPACE _SPACE_
268 # define _Locale_PRINT (_PUNCT_|_UPPER_|_LOWER_|_DIGIT_|_BLANK_)
269 # define _Locale_ALPHA (_UPPER_|_LOWER_)
270 #elif defined (__MWERKS__)
271 # define _Locale_CNTRL __control_char
272 # define _Locale_UPPER __upper_case
273 # define _Locale_LOWER __lower_case
274 # define _Locale_DIGIT __digit
275 # define _Locale_XDIGIT __hex_digit
276 # define _Locale_PUNCT __punctuation
277 # define _Locale_SPACE __space_char
278 # define _Locale_PRINT __printable
279 # define _Locale_ALPHA __alphanumeric
280 #elif defined (__BORLANDC__)
281 # define _Locale_CNTRL _IS_CTL
282 # define _Locale_UPPER _IS_UPP
283 # define _Locale_LOWER _IS_LOW
284 # define _Locale_DIGIT _IS_DIG
285 # define _Locale_XDIGIT _IS_HEX
286 # define _Locale_PUNCT _IS_PUN
287 # define _Locale_SPACE _IS_SP
288 # define _Locale_PRINT (_IS_SP|_IS_PUN|_IS_UPP|_IS_LOW|_IS_DIG)
289 # define _Locale_ALPHA _IS_ALPHA
290 #elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__)
291 # define _Locale_CNTRL _CONTROL
292 # define _Locale_UPPER _UPPER
293 # define _Locale_LOWER _LOWER
294 # define _Locale_DIGIT _DIGIT
295 # define _Locale_XDIGIT _HEX
296 # define _Locale_PUNCT _PUNCT
297 # define _Locale_SPACE _SPACE
298 # define _Locale_PRINT (_ALPHA | _DIGIT | _BLANK | _PUNCT)
299 # define _Locale_ALPHA ( _ALPHA & ~ (_UPPER | _LOWER ))
300 #elif defined (__DMC__)
301 # define _Locale_CNTRL _CONTROL
302 # define _Locale_UPPER _UPPER
303 # define _Locale_LOWER _LOWER
304 # define _Locale_DIGIT _DIGIT
305 # define _Locale_XDIGIT _HEX
306 # define _Locale_PUNCT _PUNCT
307 # define _Locale_SPACE _SPACE
308 # define _Locale_PRINT (_UPPER | _LOWER | _DIGIT | _PUNCT | _SPACE)
309 # define _Locale_ALPHA _ALPHA & ~(_UPPER | _LOWER)
310 #elif defined (__MRC__) || defined (__SC__) /* *TY 02/24/2000 - added support for MPW */
311 # define _Locale_CNTRL _CTL
312 # define _Locale_UPPER _UPP
313 # define _Locale_LOWER _LOW
314 # define _Locale_DIGIT _DIG
315 # define _Locale_XDIGIT _HEX
316 # define _Locale_PUNCT _PUN
317 # define _Locale_SPACE _BLA
318 # define _Locale_PRINT (_UPP | _LOW | _DIG | _PUN | _BLA)
319 # define _Locale_ALPHA (_UPP | _LOW)
320 #elif defined (__MLCCPP__)
321 # define _Locale_CNTRL 1
322 # define _Locale_UPPER 2
323 # define _Locale_LOWER 4
324 # define _Locale_DIGIT 8
325 # define _Locale_XDIGIT 16
326 # define _Locale_PUNCT 32
327 # define _Locale_SPACE 64
328 # define _Locale_PRINT 128
329 # define _Locale_ALPHA 256
330 #elif defined (__GNUC__) && (__GNUC__ == 3) && defined (__APPLE__)
331 # define _Locale_CNTRL _C
332 # define _Locale_UPPER _U
333 # define _Locale_LOWER _L
334 # define _Locale_DIGIT _D
335 # define _Locale_XDIGIT _X
336 # define _Locale_PUNCT _P
337 # define _Locale_SPACE _S
338 # define _Locale_PRINT _R
339 # define _Locale_ALPHA _A
340 #elif defined (__hpux) || defined (__osf__)
341 # if defined (__HP_aCC) && !defined (_INCLUDE_HPUX_SOURCE)
342 # define _ISALPHA 0x001
343 # define _ISALNUM 0x002
344 # define _ISBLANK 0x004
345 # define _ISCNTRL 0x008
346 # define _ISDIGIT 0x010
347 # define _ISGRAPH 0x020
348 # define _ISLOWER 0x040
349 # define _ISPRINT 0x080
350 # define _ISPUNCT 0x100
351 # define _ISSPACE 0x200
352 # define _ISUPPER 0x400
353 # define _ISXDIGIT 0x800
355 # define _Locale_CNTRL _ISCNTRL
356 # define _Locale_UPPER _ISUPPER
357 # define _Locale_LOWER _ISLOWER
358 # define _Locale_DIGIT _ISDIGIT
359 # define _Locale_XDIGIT _ISXDIGIT
360 # define _Locale_PUNCT _ISPUNCT
361 # define _Locale_SPACE _ISSPACE
362 # define _Locale_PRINT _ISPRINT
363 # define _Locale_ALPHA _ISALPHA
364 #elif defined (__MVS__) || defined (__OS400__)
365 # define _Locale_CNTRL __ISCNTRL
366 # define _Locale_UPPER __ISUPPER
367 # define _Locale_LOWER __ISLOWER
368 # define _Locale_DIGIT __ISDIGIT
369 # define _Locale_XDIGIT __ISXDIGIT
370 # define _Locale_PUNCT __ISPUNCT
371 # define _Locale_SPACE __ISSPACE
372 # define _Locale_PRINT __ISPRINT
373 # define _Locale_ALPHA __ISALPHA
374 #elif defined (__QNXNTO__) || defined (__WATCOMC__)
375 # define _Locale_CNTRL _CNTRL
376 # define _Locale_UPPER _UPPER
377 # define _Locale_LOWER _LOWER
378 # define _Locale_DIGIT _DIGIT
379 # define _Locale_XDIGIT _XDIGT
380 # define _Locale_PUNCT _PUNCT
381 # define _Locale_SPACE _SPACE
382 # define _Locale_PRINT _PRINT
383 # define _Locale_ALPHA (_UPPER | _LOWER)
384 #elif defined (__DJGPP)
385 # define _Locale_CNTRL __dj_ISCNTRL
386 # define _Locale_UPPER __dj_ISUPPER
387 # define _Locale_LOWER __dj_ISLOWER
388 # define _Locale_DIGIT __dj_ISDIGIT
389 # define _Locale_XDIGIT __dj_ISXDIGIT
390 # define _Locale_PUNCT __dj_ISPUNCT
391 # define _Locale_SPACE __dj_ISSPACE
392 # define _Locale_PRINT __dj_ISPRINT
393 # define _Locale_ALPHA __dj_ISALPHA
394 #elif defined (_STLP_SCO_OPENSERVER)
395 # define _Locale_CNTRL _C
396 # define _Locale_UPPER _U
397 # define _Locale_LOWER _L
398 # define _Locale_DIGIT _N
399 # define _Locale_XDIGIT _X
400 # define _Locale_PUNCT _P
401 # define _Locale_SPACE _S
402 # define _Locale_PRINT _R
403 # define _Locale_ALPHA _A
404 #elif defined (__NCR_SVR)
405 # define _Locale_CNTRL _C
406 # define _Locale_UPPER _U
407 # define _Locale_LOWER _L
408 # define _Locale_DIGIT _N
409 # define _Locale_XDIGIT _X
410 # define _Locale_PUNCT _P
411 # define _Locale_SPACE _S
412 # define _Locale_PRINT (_P | _U | _L | _N | _B)
413 # define _Locale_ALPHA (_U | _L)
414 #elif defined (_CRAY)
415 # define _Locale_CNTRL _CNTRL
416 # define _Locale_UPPER _UPPER
417 # define _Locale_LOWER _LOWER
418 # define _Locale_DIGIT _DIGIT
419 # define _Locale_XDIGIT _XDIGIT
420 # define _Locale_PUNCT _PUNCT
421 # define _Locale_SPACE _SPACE
422 # define _Locale_PRINT _PRINT
423 # define _Locale_ALPHA _ALPHA
426 /* We arbitrarily consider _Locale_CNTRL macro to check locale facet numeric
427 * identifier has been defined for the platform/compiler:
429 #if !defined (_Locale_CNTRL)
430 # error Unable to find your platform locale facets definitions, please grant them.
433 #endif /* _STLP_C_LOCALE_H */