ReactOS  0.4.15-dev-313-g8fde48b
_cwchar.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999
3  * Boris Fomitchev
4  *
5  * This material is provided "as is", with absolutely no warranty expressed
6  * or implied. Any use is at your own risk.
7  *
8  * Permission to use or copy this software for any purpose is hereby granted
9  * without fee, provided the above notices are retained on all copies.
10  * Permission to modify the code and to distribute modified code is granted,
11  * provided the above notices are retained, and a notice that the code was
12  * modified is included with the above copyright notice.
13  *
14  */
15 
16 #ifndef _STLP_INTERNAL_CWCHAR
17 #define _STLP_INTERNAL_CWCHAR
18 
19 #if defined (_STLP_WCE_EVC3)
20 # ifndef _STLP_INTERNAL_MBSTATE_T
21 # include <stl/_mbstate_t.h>
22 # endif
23 #else
24 # if defined (__GNUC__)
25 # if defined (_STLP_HAS_INCLUDE_NEXT)
26 # include_next <cstddef>
27 # else
28 # include _STLP_NATIVE_CPP_C_HEADER(cstddef)
29 # endif
30 # endif
31 
32 # if !defined (_STLP_NO_CWCHAR) && defined (_STLP_USE_NEW_C_HEADERS)
33 # if defined (_STLP_HAS_INCLUDE_NEXT)
34 # include_next <cwchar>
35 # else
36 # include _STLP_NATIVE_CPP_C_HEADER(cwchar)
37 # endif
38 # if defined (__OpenBSD__)
39 typedef _BSD_WINT_T_ wint_t;
40 # endif /* __OpenBSD__ */
41 
42 # if defined (__DMC__)
43 # define __STDC_LIMIT_MACROS
44 # include <stdint.h> // WCHAR_MIN, WCHAR_MAX
45 # endif
46 # elif defined (_STLP_NO_WCHAR_T) || \
47  (defined (__BORLANDC__) && (__BORLANDC__ < 0x570)) || \
48  defined (__OpenBSD__) || defined (__FreeBSD__) || \
49  (defined (__GNUC__) && (defined (__APPLE__) || defined ( __Lynx__ )))
50 # if defined (_STLP_HAS_INCLUDE_NEXT)
51 # include_next <stddef.h>
52 # else
53 # include _STLP_NATIVE_C_HEADER(stddef.h)
54 # endif
55 # if defined (__Lynx__)
56 # ifndef _WINT_T
57 typedef long int wint_t;
58 # define _WINT_T
59 # endif /* _WINT_T */
60 # endif
61 # if defined(__OpenBSD__)
62 typedef _BSD_WINT_T_ wint_t;
63 # endif /* __OpenBSD__ */
64 # else
65 # if defined (_STLP_HAS_INCLUDE_NEXT)
66 # include_next <wchar.h>
67 # else
68 # include _STLP_NATIVE_C_HEADER(wchar.h)
69 # endif
70 
71 # if defined (__sun) && (defined (_XOPEN_SOURCE) || (_XOPEN_VERSION - 0 == 4))
72 extern wint_t btowc();
73 extern int fwprintf();
74 extern int fwscanf();
75 extern int fwide();
76 extern int mbsinit();
77 extern size_t mbrlen();
78 extern size_t mbrtowc();
79 extern size_t mbsrtowcs();
80 extern int swprintf();
81 extern int swscanf();
82 extern int vfwprintf();
83 extern int vwprintf();
84 extern int vswprintf();
85 extern size_t wcrtomb();
86 extern size_t wcsrtombs();
87 extern wchar_t *wcsstr();
88 extern int wctob();
89 extern wchar_t *wmemchr();
90 extern int wmemcmp();
91 extern wchar_t *wmemcpy();
92 extern wchar_t *wmemmove();
93 extern wchar_t *wmemset();
94 extern int wprintf();
95 extern int wscanf();
96 # endif
97 # endif
98 
99 # if defined (__MSL__) && (__MSL__ <= 0x51FF) /* dwa 2/28/99 - not yet implemented by MSL */
100 # define _STLP_WCHAR_MSL_EXCLUDE 1
101 namespace std {
102  extern "C" size_t wcsftime(wchar_t * str, size_t max_size, const wchar_t * format_str, const struct tm * timeptr);
103 }
104 # define _STLP_NO_NATIVE_MBSTATE_T 1
105 # elif defined (__BORLANDC__)
106 # if !defined (_STLP_USE_NO_IOSTREAMS)
107 # define _STLP_NO_NATIVE_MBSTATE_T
108 # endif
109 # define _STLP_WCHAR_BORLAND_EXCLUDE 1
110 # endif
111 
112 # ifndef _STLP_INTERNAL_MBSTATE_T
113 # include <stl/_mbstate_t.h>
114 # endif
115 
116 # if !defined (_STLP_NO_WCHAR_T)
117 # ifndef WCHAR_MIN
118 # define WCHAR_MIN 0
119 /* SUNpro has some bugs with casts. wchar_t is size of int there anyway. */
120 # if defined (__SUNPRO_CC) || defined (__DJGPP)
121 # define WCHAR_MAX (~0)
122 # else
123 # define WCHAR_MAX ((wchar_t)~0)
124 # endif
125 # endif
126 # if defined (__DMC__) || (defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400)) || defined(_WIN32_WCE)
127 /* Compilers that do not define WCHAR_MIN and WCHAR_MAX to be testable at
128  * preprocessing time. */
129 # undef WCHAR_MIN
130 # define WCHAR_MIN 0
131 # undef WCHAR_MAX
132 # define WCHAR_MAX 0xffff
133 # endif
134 # if defined (__GNUC__) && defined (__alpha__)
135 /* Definition of WCHAR_MIN and MAX are wrong for alpha platform
136  * as gcc consider wchar_t as an unsigned type but WCHAR_MIN is defined as
137  * a negative value. Static assertion is here to check that a future alpha
138  * SDK or a future gcc won't change the situation making this workaround
139  * useless.
140  */
141 /* Check that gcc still consider wchar_t as unsigned */
142 _STLP_STATIC_ASSERT(((wchar_t)-1 > 0))
143 /* Check that WCHAR_MIN value hasn't been fixed */
145 # undef WCHAR_MIN
146 # define WCHAR_MIN 0
147 # undef WCHAR_MAX
148 # define WCHAR_MAX 0xffffffff
149 # endif
150 # if defined(__HP_aCC) && (__HP_aCC >= 60000)
151 /* Starting with B.11.31, HP-UX/ia64 provides C99-compliant definitions
152  * of WCHAR_MIN/MAX macros without having to define
153  * _INCLUDE_STDC__SOURCE_199901 macro (which aCC compiler does not
154  * predefine). Let STLport provide B.11.31 definitions on any version of
155  * HP-UX/ia64.
156  */
157 # undef WCHAR_MIN
158 # define WCHAR_MIN 0
159 # undef WCHAR_MAX
160 # define WCHAR_MAX UINT_MAX
161 # endif
162 # endif
163 
164 # if defined (_STLP_IMPORT_VENDOR_CSTD)
165 
166 # if defined (__SUNPRO_CC) && !defined (_STLP_HAS_NO_NEW_C_HEADERS)
168 # endif
169 
171 # if defined (_STLP_NO_WCHAR_T)
172 typedef int wint_t;
173 # else
174 // gcc 3.0 has a glitch : wint_t only sucked into the global namespace if _GLIBCPP_USE_WCHAR_T is defined
175 // __MWERKS__ has definition in wchar_t.h (MSL C++), but ones differ from definition
176 // in stdio.h; I prefer settings from last file.
177 # if (defined (__GNUC__) && ! defined (_GLIBCPP_USE_WCHAR_T))
179 # else
181 # endif
182 # endif
183 
185 
186 # if !defined (_STLP_NO_NATIVE_MBSTATE_T) && !defined (_STLP_USE_OWN_MBSTATE_T)
188 
189 # if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !defined(_STLP_WCHAR_BORLAND_EXCLUDE) && \
190  (!defined(__MSL__) || __MSL__ > 0x6001)
191 # if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \
192  !(defined (__KCC) || defined (__GNUC__)) && !defined(_STLP_WCE_NET)
194 # if (!defined(__MSL__) || __MSL__ > 0x7001)
196 # endif
197 # endif
198 # if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \
199  !defined (__GNUC__) && !defined(_STLP_WCE_NET)
205 # endif
206 # endif /* BORLAND && !__MSL__ || __MSL__ > 0x6001 */
207 
208 # endif /* _STLP_NO_NATIVE_MBSTATE_T */
209 
210 # if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
211 
212 # if !defined (_STLP_WCHAR_BORLAND_EXCLUDE) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
217 # endif
218 
219 # if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \
220  defined(_STLP_WCHAR_HPACC_EXCLUDE) )
221 # if !defined (__DECCXX)
223 # endif
227 # endif
228 
229 # if !defined(_STLP_WCHAR_BORLAND_EXCLUDE)
230 # ifndef _STLP_WCE_NET
232 # endif
234 # ifndef _STLP_WCE_NET
236 # endif
238 # endif
239 
240 # if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \
241  defined (_STLP_WCHAR_HPACC_EXCLUDE) )
242 # if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB <= 1300) || \
243  defined (__MINGW32__)
244 # undef swprintf
245 # define swprintf _snwprintf
246 # undef vswprintf
247 # define vswprintf _vsnwprintf
250 # else
253 # endif
257 
258 # if (!defined(__MSL__) || __MSL__ > 0x7001 ) && !defined(_STLP_WCE_NET) && \
259  !defined(_STLP_USE_UCLIBC) /* at least in uClibc 0.9.26 */
260 
262 # endif
264 
265 # endif
266 
267 # if !defined (_STLP_WCE_NET)
270 # endif
274 
277 
284 
286 
287 # if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
290 # endif
291 
292 # if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_HPACC_EXCLUDE) )
295 
296 # if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
297 # if !defined (_STLP_WCE_NET)
299 # endif
300 # if !defined (__DMC__)
303 # endif
306 # endif
307 
308 # if defined (__BORLANDC__) && !defined (__linux__)
309 inline wchar_t* _STLP_wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n)
310 { return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::wmemcpy(__wdst, __wsrc, __n)); }
311 inline wchar_t* _STLP_wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
312 { return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::memset(__wdst, __wc, __n)); }
313 # undef wmemcpy
314 # undef wmemset
315 inline wchar_t* wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n)
316 { return _STLP_wmemcpy(__wdst, __wsrc, __n); }
317 inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
318 { return _STLP_wmemset(__wdst, __wc, __n); }
319 # elif defined (__DMC__)
320 inline wchar_t* wmemcpy(wchar_t* __RESTRICT __wdst, const wchar_t* __RESTRICT __wsrc, size_t __n)
321 { return __STATIC_CAST(wchar_t*, memcpy(__wdst, __wsrc, __n * sizeof(wchar_t))); }
322 inline wchar_t* wmemmove(wchar_t* __RESTRICT __wdst, const wchar_t * __RESTRICT __wc, size_t __n)
323 { return __STATIC_CAST(wchar_t*, memmove(__wdst, __wc, __n * sizeof(wchar_t))); }
324 inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
325 { for (size_t i = 0; i < __n; i++) __wdst[i] = __wc; return __wdst; }
326 # else
327 using _STLP_VENDOR_CSTD::wmemcpy;
329 # endif
330 # endif
331 
332 # endif /* _STLP_NO_NATIVE_WIDE_FUNCTIONS */
334 
335 # endif /* _STLP_IMPORT_VENDOR_CSTD */
336 
337 # undef _STLP_WCHAR_SUNPRO_EXCLUDE
338 # undef _STLP_WCHAR_MSL_EXCLUDE
339 
340 # endif /* !defined(_STLP_WCE_EVC3) */
341 
342 #endif /* _STLP_INTERNAL_CWCHAR */
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
return __n
Definition: _algo.h:75
_Check_return_opt_ _CRTIMP size_t __cdecl wcsxfrm(_Out_writes_opt_(_MaxCount) _Post_maybez_ wchar_t *_Dst, _In_z_ const wchar_t *_Src, _In_ size_t _MaxCount)
wint_t __cdecl btowc(int)
_Check_return_ _CRTIMP int __cdecl wcscoll(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define putwc(_c, _stm)
Definition: stdio.h:1108
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
#define wint_t
Definition: _sunprocc.h:96
_Check_return_ _CRTIMP size_t __cdecl wcscspn(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
_Check_return_opt_ _CRTIMP wint_t __cdecl ungetwc(_In_ wint_t _Ch, _Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl wscanf(_In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define wprintf(...)
Definition: whoami.c:18
Definition: features.h:417
size_t CDECL wcsftime(wchar_t *str, size_t max, const wchar_t *format, const struct tm *mstm)
Definition: strftime.c:302
#define getwc(_stm)
Definition: stdio.h:1107
_CONST_RETURN wchar_t *__cdecl wmemchr(_In_reads_(_N) const wchar_t *_S, _In_ wchar_t _C, _In_ size_t _N)
Definition: wchar.h:2536
__CRT_INLINE int __cdecl fwide(_In_opt_ FILE *_F, int _M)
Definition: wchar.h:2515
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_opt_ _CRTIMP int __cdecl fputws(_In_z_ const wchar_t *_Str, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fwprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const wchar_t *_Format,...)
static INT max_size
Definition: history.c:51
size_t __cdecl mbrtowc(_Pre_maybenull_ _Post_z_ wchar_t *_DstCh, _In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ const char *_SrcCh, _In_ size_t _SizeInBytes, _Out_opt_ mbstate_t *_State)
_Check_return_ _CRTIMP int __cdecl fwscanf(_Inout_ FILE *_File, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
int wint_t
Definition: _apple.h:38
const WCHAR * str
size_t __cdecl wcsrtombs(_Pre_maybenull_ _Post_z_ char *_Dest, _Inout_ _Deref_prepost_z_ const wchar_t **_PSource, _In_ size_t _Count, _Out_opt_ mbstate_t *_State)
_Check_return_opt_ _CRTIMP int __cdecl vfwprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
__mbstate_t mbstate_t
Definition: _sunprocc.h:158
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
_Check_return_opt_ _CRTIMP int __cdecl vwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
__kernel_size_t size_t
Definition: linux.h:237
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
_STLP_STATIC_ASSERT(sizeof(nl_catd_type)<=sizeof(int)) class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map
#define swprintf(buf, format,...)
Definition: sprintf.c:56
wchar_t *__cdecl wmemset(_Out_writes_all_(_N) wchar_t *_S, _In_ wchar_t _C, _In_ size_t _N)
Definition: wchar.h:2593
int __cdecl wctob(_In_ wint_t _WCh)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: time.h:76
_CRTIMP wchar_t *__cdecl wcsncat(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_Check_return_ double __cdecl wcstod(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define WCHAR_MIN
Definition: _cwchar.h:118
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
wint_t CDECL getwchar(void)
Definition: file.c:3035
#define _STLP_END_NAMESPACE
Definition: features.h:503
size_t __cdecl mbsrtowcs(_Pre_notnull_ _Post_z_ wchar_t *_Dest, _Inout_ _Deref_prepost_opt_valid_ const char **_PSrc, _In_ size_t _Count, _Inout_opt_ mbstate_t *_State)
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
int __cdecl wmemcmp(_In_reads_(_N) const wchar_t *_S1, _In_reads_(_N) const wchar_t *_S2, _In_ size_t _N)
Definition: wchar.h:2551
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
_Check_return_opt_ _CRTIMP wint_t __cdecl fgetwc(_Inout_ FILE *_File)
#define putwchar(_c)
Definition: stdio.h:1101
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
size_t __cdecl mbrlen(_In_reads_bytes_opt_(_SizeInBytes) _Pre_opt_z_ const char *_Ch, _In_ size_t _SizeInBytes, _Out_opt_ mbstate_t *_State)
_Check_return_opt_ _CRTIMP wint_t __cdecl fputwc(_In_ wchar_t _Ch, _Inout_ FILE *_File)
#define memset(x, y, z)
Definition: compat.h:39
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
_CRTIMP int __cdecl vswprintf(_Out_ wchar_t *, const wchar_t *, va_list)
_Check_return_ _CRTIMP size_t __cdecl wcsspn(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
__CRT_INLINE int __cdecl mbsinit(_In_opt_ const mbstate_t *_P)
Definition: wchar.h:2526
size_t __cdecl wcrtomb(_Pre_maybenull_ _Post_z_ char *_Dest, _In_ wchar_t _Source, _Out_opt_ mbstate_t *_State)
wchar_t *__cdecl wmemmove(_Out_writes_all_opt_(_N) wchar_t *_S1, _In_reads_opt_(_N) const wchar_t *_S2, _In_ size_t _N)
Definition: wchar.h:2582