2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
13 * Permission to use or copy this software for any purpose is hereby granted
14 * without fee, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
22 #ifndef _STLP_C_LOCALE_H
23 # define _STLP_C_LOCALE_H
26 * Implementation dependent definitions
29 # include <stl/_config.h>
33 # if defined(ROOT_65) /* IRIX 6.5.x */
35 # include <standards.h>
42 # include <standards.h>
44 # if !defined(_SIZE_T) && !defined(_SIZE_T_)
46 # if (_MIPS_SZLONG == 32)
47 typedef unsigned int size_t;
49 # if (_MIPS_SZLONG == 64)
50 typedef unsigned long size_t;
56 # if (_MIPS_SZLONG == 32)
59 # if (_MIPS_SZLONG == 64)
60 typedef __int32_t wchar_t;
62 # endif /* _WCHAR_T */
66 # if (_MIPS_SZLONG == 32)
69 # if (_MIPS_SZLONG == 64)
70 typedef __int32_t wint_t;
77 typedef int mbstate_t;
79 typedef char mbstate_t;
81 # endif /* _MBSTATE_T */
88 # ifndef _STLP_CSTDDEF
91 # ifndef _STLP_CWCHAR_H
92 # include <stl/_cwchar.h>
109 struct _Locale_ctype;
110 struct _Locale_numeric;
112 struct _Locale_collate;
113 struct _Locale_monetary;
114 struct _Locale_messages;
121 * For narrow characters, we expose the lookup table interface.
124 /* Internal bitmask macros, os-specific. */
126 #if defined(__sgi) /* IRIX */
128 #define _Locale_S 0x00000008 /* Spacing character */
129 #define _Locale_A 0x00004000 /* Alphabetical characters only */
130 #define _Locale_B 0x00000040 /* Obsolete: was space char only */
131 #define _Locale_PR 0x00008000 /* Printable characters only */
132 #define _Locale_G 0x40000000 /* Graphic characters only */
133 #define _Locale_BL 0x80000000 /* The blank character class */
135 /* Public bitmask macros, must be defined for every OS. These values, of
136 * course, are specific to IRIX. */
138 #define _Locale_CNTRL 0x00000020 /* Control character */
139 #define _Locale_UPPER 0x00000001 /* Upper case */
140 #define _Locale_LOWER 0x00000002 /* Lower case */
141 #define _Locale_DIGIT 0x00000004 /* Numeral (digit) */
142 #define _Locale_XDIGIT 0x00000080 /* heXadecimal digit */
143 #define _Locale_PUNCT 0x00000010 /* Punctuation */
144 #define _Locale_SPACE (_Locale_S | _Locale_BL)
145 #define _Locale_PRINT (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
146 _Locale_DIGIT | _Locale_A | _Locale_XDIGIT | \
148 #define _Locale_ALPHA _Locale_A
151 * All of these except for graph and blank are from the C standard;
152 * graph and blank are XPG4. (graph in XPG4 doesn't mean quite the
153 * same thing as graph in the C++ library)
159 #if defined( __Lynx__ )
160 /* azov: On Lynx isalpha defined as (_U | _L), which gives us a mask
161 * unusable in ctype_table. So we have to redefine it and use hard-coded
162 * numbers (to avoid potential clashes if system headers change).
164 * P.S. Actually, I see no reason in using platform-specific masks -
165 * having just one set of masks for all platforms should work just as
166 * well - we only use them internally and they don't have to be equal
167 * to whatever defined in local ctype.h
170 # define _Locale_CNTRL 040 /* _C, Control character */
171 # define _Locale_UPPER 01 /* _U, Upper case */
172 # define _Locale_LOWER 02 /* _L, Lower case */
173 # define _Locale_DIGIT 04 /* _N, Numeral (digit) */
174 # define _Locale_XDIGIT 0200 /* _X, heXadecimal digit */
175 # define _Locale_PUNCT 020 /* _P, Punctuation */
176 # define _Locale_SPACE 010 /* _S, Spacing */
177 # define _Locale_ALPHA 040000 /* none, Alphanumerical */
178 # define _Locale_PRINT (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
179 _Locale_DIGIT | _Locale_ALPHA | _Locale_XDIGIT |\
180 _Locale_SPACE ) /* Printable */
181 # endif /* __Lynx__ */
183 #if defined(__GNUC__) || defined (__BORLANDC__) || defined (__COMO__)
185 # if defined (__CYGWIN__)
187 # define _Locale_CNTRL 040
188 # define _Locale_UPPER 02
189 # define _Locale_LOWER 01
190 # define _Locale_DIGIT 04
191 # define _Locale_XDIGIT ( 0100 | _Locale_DIGIT )
192 # define _Locale_PUNCT 020
193 # define _Locale_SPACE 010
194 # define _Locale_ALPHA (_Locale_UPPER | _Locale_LOWER)
195 # define _Locale_PRINT (_Locale_ALPHA | _Locale_DIGIT | _Locale_PUNCT | 0200 )
197 # elif defined (__FreeBSD__)
199 # define _Locale_CNTRL _CTYPE_C
200 # define _Locale_UPPER _CTYPE_U
201 # define _Locale_LOWER _CTYPE_L
202 # define _Locale_DIGIT _CTYPE_D
203 # define _Locale_XDIGIT _CTYPE_X
204 # define _Locale_PUNCT _CTYPE_P
205 # define _Locale_SPACE _CTYPE_S
206 # define _Locale_PRINT _CTYPE_R
207 # define _Locale_ALPHA _CTYPE_A
209 # elif defined (__NetBSD__) || defined (__amigaos__)
211 # define _Locale_CNTRL _C
212 # define _Locale_UPPER _U
213 # define _Locale_LOWER _L
214 # define _Locale_DIGIT _N
215 # define _Locale_XDIGIT (_N|_X)
216 # define _Locale_PUNCT _P
217 # define _Locale_SPACE _S
218 # define _Locale_PRINT (_P|_U|_L|_N|_B)
219 # define _Locale_ALPHA (_U|_L)
220 # elif defined(__EMX__) /* OS/2 with emx runtime */
221 # define _Locale_CNTRL _CNTRL
222 # define _Locale_UPPER _UPPER
223 # define _Locale_LOWER _LOWER
224 # define _Locale_DIGIT _DIGIT
225 # define _Locale_XDIGIT _XDIGIT
226 # define _Locale_PUNCT _PUNCT
227 # define _Locale_SPACE _SPACE
228 # define _Locale_PRINT _PRINT
229 # define _Locale_ALPHA (_UPPER|_LOWER)
231 # elif defined(_STLP_USE_GLIBC) /* linux, using the gnu compiler */
233 /* This section uses macros defined in the gnu libc ctype.h header */
235 # define _Locale_CNTRL _IScntrl
236 # define _Locale_UPPER _ISupper
237 # define _Locale_LOWER _ISlower
238 # define _Locale_DIGIT _ISdigit
239 # define _Locale_XDIGIT _ISxdigit
240 # define _Locale_PUNCT _ISpunct
241 # define _Locale_SPACE _ISspace
242 # define _Locale_PRINT _ISprint
243 # define _Locale_ALPHA _ISalpha
249 #if ( defined(__sun) && defined (__SVR4) ) \
250 || (defined (__digital__) && defined (__unix__)) \
252 /* fbp : condition from AT&T code*/
253 #if !(defined(__XPG4_CHAR_CLASS__) || defined(_XPG4_2) || \
254 (defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4))) && ! defined (_ISCNTRL)
255 /* fbp : on 2.5.1, the defines are different ;( */
256 // # if ( defined (__sun) && defined (__SVR4) && ! defined (_ISCNTRL) )
261 # define _ISXDIGIT _X
264 # define _ISPRINT (_P | _U | _L | _N | _B)
265 # define _ISALPHA (_U | _L)
268 # define _Locale_CNTRL _ISCNTRL
269 # define _Locale_UPPER _ISUPPER
270 # define _Locale_LOWER _ISLOWER
271 # define _Locale_DIGIT _ISDIGIT
272 # define _Locale_XDIGIT _ISXDIGIT
273 # define _Locale_PUNCT _ISPUNCT
274 # define _Locale_SPACE _ISSPACE
275 # define _Locale_PRINT _ISPRINT
276 # define _Locale_ALPHA _ISALPHA
277 # elif defined(__SYMBIAN32__)
278 # define _Locale_CNTRL _CTYPE_C
279 # define _Locale_UPPER _CTYPE_U
280 # define _Locale_LOWER _CTYPE_L
281 # define _Locale_DIGIT _CTYPE_D
282 # define _Locale_XDIGIT _CTYPE_X
283 # define _Locale_PUNCT _CTYPE_P
284 # define _Locale_SPACE _CTYPE_S
285 # define _Locale_PRINT _CTYPE_R
286 # define _Locale_ALPHA _CTYPE_A
288 #elif defined (__MWERKS__)
289 # define _Locale_CNTRL __control_char
290 # define _Locale_UPPER __upper_case
291 # define _Locale_LOWER __lower_case
292 # define _Locale_DIGIT __digit
293 # define _Locale_XDIGIT __hex_digit
294 # define _Locale_PUNCT __punctuation
295 # define _Locale_SPACE __space_char
296 # define _Locale_PRINT __printable
297 # define _Locale_ALPHA __alphanumeric
298 #elif defined (__BORLANDC__)
299 # define _Locale_CNTRL _IS_CTL
300 # define _Locale_UPPER _IS_UPP
301 # define _Locale_LOWER _IS_LOW
302 # define _Locale_DIGIT _IS_DIG
303 # define _Locale_XDIGIT _IS_HEX
304 # define _Locale_PUNCT _IS_PUN
305 # define _Locale_SPACE _IS_SP
306 # define _Locale_PRINT (_IS_SP|_IS_PUN|_IS_UPP|_IS_LOW|_IS_DIG)
307 # define _Locale_ALPHA _IS_ALPHA
308 #elif defined (_MSC_VER) || defined (__MINGW32__)
309 # define _Locale_CNTRL _CONTROL
310 # define _Locale_UPPER _UPPER
311 # define _Locale_LOWER _LOWER
312 # define _Locale_DIGIT _DIGIT
313 # define _Locale_XDIGIT _HEX
314 # define _Locale_PUNCT _PUNCT
315 # define _Locale_SPACE _SPACE
316 # define _Locale_PRINT (_ALPHA | _DIGIT | _BLANK | _PUNCT)
317 // is this one has to be so complex ?
318 # define _Locale_ALPHA ( _ALPHA & ~ (_UPPER | _LOWER ))
319 #elif defined (__DMC__)
320 # define _Locale_CNTRL _CONTROL
321 # define _Locale_UPPER _UPPER
322 # define _Locale_LOWER _LOWER
323 # define _Locale_DIGIT _DIGIT
324 # define _Locale_XDIGIT _HEX
325 # define _Locale_PUNCT _PUNCT
326 # define _Locale_SPACE _SPACE
327 # define _Locale_PRINT (_UPPER | _LOWER | _DIGIT | _PUNCT | _SPACE)
328 # define _Locale_ALPHA _ALPHA
329 #elif defined(__MRC__) || defined(__SC__) //*TY 02/24/2000 - added support for MPW
330 # define _Locale_CNTRL _CTL
331 # define _Locale_UPPER _UPP
332 # define _Locale_LOWER _LOW
333 # define _Locale_DIGIT _DIG
334 # define _Locale_XDIGIT _HEX
335 # define _Locale_PUNCT _PUN
336 # define _Locale_SPACE _BLA
337 # define _Locale_PRINT (_UPP | _LOW | _DIG | _PUN | _BLA)
338 # define _Locale_ALPHA (_UPP | _LOW)
339 #elif defined(__MLCCPP__)
340 # define _Locale_CNTRL 1
341 # define _Locale_UPPER 2
342 # define _Locale_LOWER 4
343 # define _Locale_DIGIT 8
344 # define _Locale_XDIGIT 16
345 # define _Locale_PUNCT 32
346 # define _Locale_SPACE 64
347 # define _Locale_PRINT 128
348 # define _Locale_ALPHA 256
350 # elif defined (__GNUC__) && defined (__APPLE__)
352 # define _Locale_CNTRL _C
353 # define _Locale_UPPER _U
354 # define _Locale_LOWER _L
355 # define _Locale_DIGIT _D
356 # define _Locale_XDIGIT _X
357 # define _Locale_PUNCT _P
358 # define _Locale_SPACE _S
359 # define _Locale_PRINT _R
360 # define _Locale_ALPHA _A
362 # elif defined (__hpux) || defined (__osf__)
364 # if defined(__HP_aCC) && !defined(_INCLUDE_HPUX_SOURCE)
365 # define _ISALPHA 0x001
366 # define _ISALNUM 0x002
367 # define _ISBLANK 0x004
368 # define _ISCNTRL 0x008
369 # define _ISDIGIT 0x010
370 # define _ISGRAPH 0x020
371 # define _ISLOWER 0x040
372 # define _ISPRINT 0x080
373 # define _ISPUNCT 0x100
374 # define _ISSPACE 0x200
375 # define _ISUPPER 0x400
376 # define _ISXDIGIT 0x800
378 # define _Locale_CNTRL _ISCNTRL
379 # define _Locale_UPPER _ISUPPER
380 # define _Locale_LOWER _ISLOWER
381 # define _Locale_DIGIT _ISDIGIT
382 # define _Locale_XDIGIT _ISXDIGIT
383 # define _Locale_PUNCT _ISPUNCT
384 # define _Locale_SPACE _ISSPACE
385 # define _Locale_PRINT _ISPRINT
386 # define _Locale_ALPHA _ISALPHA
387 # elif defined (__MVS__) || defined(__OS400__)
388 # define _Locale_CNTRL __ISCNTRL
389 # define _Locale_UPPER __ISUPPER
390 # define _Locale_LOWER __ISLOWER
391 # define _Locale_DIGIT __ISDIGIT
392 # define _Locale_XDIGIT __ISXDIGIT
393 # define _Locale_PUNCT __ISPUNCT
394 # define _Locale_SPACE __ISSPACE
395 # define _Locale_PRINT __ISPRINT
396 # define _Locale_ALPHA __ISALPHA
397 # elif defined (__QNXNTO__) || defined (__WATCOMC__)
398 # define _Locale_CNTRL _CNTRL
399 # define _Locale_UPPER _UPPER
400 # define _Locale_LOWER _LOWER
401 # define _Locale_DIGIT _DIGIT
402 # define _Locale_XDIGIT _XDIGT
403 # define _Locale_PUNCT _PUNCT
404 # define _Locale_SPACE _SPACE
405 # define _Locale_PRINT _PRINT
406 # define _Locale_ALPHA (_UPPER | _LOWER)
407 #elif defined (__DJGPP)
408 # define _Locale_CNTRL __dj_ISCNTRL
409 # define _Locale_UPPER __dj_ISUPPER
410 # define _Locale_LOWER __dj_ISLOWER
411 # define _Locale_DIGIT __dj_ISDIGIT
412 # define _Locale_XDIGIT __dj_ISXDIGIT
413 # define _Locale_PUNCT __dj_ISPUNCT
414 # define _Locale_SPACE __dj_ISSPACE
415 # define _Locale_PRINT __dj_ISPRINT
416 # define _Locale_ALPHA __dj_ISALPHA
417 #elif defined (_STLP_SCO_OPENSERVER)
418 # define _Locale_CNTRL _C
419 # define _Locale_UPPER _U
420 # define _Locale_LOWER _L
421 # define _Locale_DIGIT _N
422 # define _Locale_XDIGIT _X
423 # define _Locale_PUNCT _P
424 # define _Locale_SPACE _S
425 # define _Locale_PRINT _R
426 # define _Locale_ALPHA _A
427 #elif defined (__NCR_SVR)
428 # define _Locale_CNTRL _C
429 # define _Locale_UPPER _U
430 # define _Locale_LOWER _L
431 # define _Locale_DIGIT _N
432 # define _Locale_XDIGIT _X
433 # define _Locale_PUNCT _P
434 # define _Locale_SPACE _S
435 # define _Locale_PRINT (_P | _U | _L | _N | _B)
436 # define _Locale_ALPHA (_U | _L)
437 #elif defined (_CRAY)
438 # define _Locale_CNTRL _CNTRL
439 # define _Locale_UPPER _UPPER
440 # define _Locale_LOWER _LOWER
441 # define _Locale_DIGIT _DIGIT
442 # define _Locale_XDIGIT _XDIGIT
443 # define _Locale_PUNCT _PUNCT
444 # define _Locale_SPACE _SPACE
445 # define _Locale_PRINT _PRINT
446 # define _Locale_ALPHA _ALPHA
447 #elif defined (_STLP_VXWORKS_TORNADO)
448 #define _Locale_UPPER _C_UPPER /* 0x01 */
449 #define _Locale_LOWER _C_LOWER /* 0x02 */
450 #define _Locale_DIGIT _C_NUMBER /* 0x04 */
451 #define _Locale_SPACE _C_WHITE_SPACE /* 0x08 */
452 #define _Locale_PUNCT _C_PUNCT /* 0x10 */
453 #define _Locale_CNTRL _C_CONTROL /* 0x20 */
454 #define _Locale_XDIGIT _C_HEX_NUMBER /* 0x40 */
455 #define _Locale_PRINT (_C_B | _C_UPPER | _C_LOWER | _C_NUMBER | _C_PUNCT)
456 #define _Locale_ALPHA (_C_UPPER | _C_LOWER)
459 # endif /* _STLP_C_LOCALE_H */