2 * Copyright 2010 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
29 /* char_traits<char> */
30 /* ?assign@?$char_traits@D@std@@SAXAADABD@Z */
31 /* ?assign@?$char_traits@D@std@@SAXAEADAEBD@Z */
32 void CDECL MSVCP_char_traits_char_assign(char *ch, const char *assign)
37 /* ?eq@?$char_traits@D@std@@SA_NABD0@Z */
38 /* ?eq@?$char_traits@D@std@@SA_NAEBD0@Z */
39 MSVCP_BOOL CDECL MSVCP_char_traits_char_eq(const char *ch1, const char *ch2)
44 /* ?lt@?$char_traits@D@std@@SA_NABD0@Z */
45 /* ?lt@?$char_traits@D@std@@SA_NAEBD0@Z */
46 MSVCP_BOOL CDECL MSVCP_char_traits_lt(const char *ch1, const char *ch2)
51 /* ?compare@?$char_traits@D@std@@SAHPBD0I@Z */
52 /* ?compare@?$char_traits@D@std@@SAHPEBD0_K@Z */
53 int CDECL MSVCP_char_traits_char_compare(
54 const char *s1, const char *s2, size_t count)
56 int ret = memcmp(s1, s2, count);
57 return (ret>0 ? 1 : (ret<0 ? -1 : 0));
60 /* ?length@?$char_traits@D@std@@SAIPBD@Z */
61 /* ?length@?$char_traits@D@std@@SA_KPEBD@Z */
62 size_t CDECL MSVCP_char_traits_char_length(const char *str)
67 /* ?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z */
68 /* ?_Copy_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z */
69 char* CDECL MSVCP_char_traits_char__Copy_s(char *dest,
70 size_t size, const char *src, size_t count)
72 if(!dest || !src || size<count) {
75 _invalid_parameter(NULL, NULL, NULL, 0, 0);
79 return memcpy(dest, src, count);
82 /* ?copy@?$char_traits@D@std@@SAPADPADPBDI@Z */
83 /* ?copy@?$char_traits@D@std@@SAPEADPEADPEBD_K@Z */
84 char* CDECL MSVCP_char_traits_char_copy(
85 char *dest, const char *src, size_t count)
87 return MSVCP_char_traits_char__Copy_s(dest, count, src, count);
90 /* ?find@?$char_traits@D@std@@SAPBDPBDIABD@Z */
91 /* ?find@?$char_traits@D@std@@SAPEBDPEBD_KAEBD@Z */
92 const char * CDECL MSVCP_char_traits_char_find(
93 const char *str, size_t range, const char *c)
95 return memchr(str, *c, range);
98 /* ?_Move_s@?$char_traits@D@std@@SAPADPADIPBDI@Z */
99 /* ?_Move_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z */
100 char* CDECL MSVCP_char_traits_char__Move_s(char *dest,
101 size_t size, const char *src, size_t count)
103 if(!dest || !src || size<count) {
106 _invalid_parameter(NULL, NULL, NULL, 0, 0);
110 return memmove(dest, src, count);
113 /* ?move@?$char_traits@D@std@@SAPADPADPBDI@Z */
114 /* ?move@?$char_traits@D@std@@SAPEADPEADPEBD_K@Z */
115 char* CDECL MSVCP_char_traits_char_move(
116 char *dest, const char *src, size_t count)
118 return MSVCP_char_traits_char__Move_s(dest, count, src, count);
121 /* ?assign@?$char_traits@D@std@@SAPADPADID@Z */
122 /* ?assign@?$char_traits@D@std@@SAPEADPEAD_KD@Z */
123 char* CDECL MSVCP_char_traits_char_assignn(char *str, size_t num, char c)
125 return memset(str, c, num);
128 /* ?to_char_type@?$char_traits@D@std@@SADABH@Z */
129 /* ?to_char_type@?$char_traits@D@std@@SADAEBH@Z */
130 char CDECL MSVCP_char_traits_char_to_char_type(const int *i)
135 /* ?to_int_type@?$char_traits@D@std@@SAHABD@Z */
136 /* ?to_int_type@?$char_traits@D@std@@SAHAEBD@Z */
137 int CDECL MSVCP_char_traits_char_to_int_type(const char *ch)
142 /* ?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z */
143 /* ?eq_int_type@?$char_traits@D@std@@SA_NAEBH0@Z */
144 MSVCP_BOOL CDECL MSVCP_char_traits_char_eq_int_type(const int *i1, const int *i2)
149 /* ?eof@?$char_traits@D@std@@SAHXZ */
150 int CDECL MSVCP_char_traits_char_eof(void)
155 /* ?not_eof@?$char_traits@D@std@@SAHABH@Z */
156 /* ?not_eof@?$char_traits@D@std@@SAHAEBH@Z */
157 int CDECL MSVCP_char_traits_char_not_eof(int *in)
159 return (*in==EOF ? !EOF : *in);
163 /* char_traits<wchar_t> */
164 /* ?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z */
165 /* ?assign@?$char_traits@_W@std@@SAXAEA_WAEB_W@Z */
166 void CDECL MSVCP_char_traits_wchar_assign(wchar_t *ch,
167 const wchar_t *assign)
172 /* ?eq@?$char_traits@_W@std@@SA_NAB_W0@Z */
173 /* ?eq@?$char_traits@_W@std@@SA_NAEB_W0@Z */
174 MSVCP_BOOL CDECL MSVCP_char_traits_wchar_eq(wchar_t *ch1, wchar_t *ch2)
179 /* ?lt@?$char_traits@_W@std@@SA_NAB_W0@Z */
180 /* ?lt@?$char_traits@_W@std@@SA_NAEB_W0@Z */
181 MSVCP_BOOL CDECL MSVCP_char_traits_wchar_lt(const wchar_t *ch1,
187 /* ?compare@?$char_traits@_W@std@@SAHPB_W0I@Z */
188 /* ?compare@?$char_traits@_W@std@@SAHPEB_W0_K@Z */
189 int CDECL MSVCP_char_traits_wchar_compare(const wchar_t *s1,
190 const wchar_t *s2, size_t count)
192 int ret = memcmp(s1, s2, sizeof(wchar_t[count]));
193 return (ret>0 ? 1 : (ret<0 ? -1 : 0));
196 /* ?length@?$char_traits@_W@std@@SAIPB_W@Z */
197 /* ?length@?$char_traits@_W@std@@SA_KPEB_W@Z */
198 size_t CDECL MSVCP_char_traits_wchar_length(const wchar_t *str)
200 return wcslen((WCHAR*)str);
203 /* ?_Copy_s@?$char_traits@_W@std@@SAPA_WPA_WIPB_WI@Z */
204 /* ?_Copy_s@?$char_traits@_W@std@@SAPEA_WPEA_W_KPEB_W1@Z */
205 wchar_t* CDECL MSVCP_char_traits_wchar__Copy_s(wchar_t *dest,
206 size_t size, const wchar_t *src, size_t count)
208 if(!dest || !src || size<count) {
211 _invalid_parameter(NULL, NULL, NULL, 0, 0);
215 return memcpy(dest, src, sizeof(wchar_t[count]));
218 /* ?copy@?$char_traits@_W@std@@SAPA_WPA_WPB_WI@Z */
219 /* ?copy@?$char_traits@_W@std@@SAPEA_WPEA_WPEB_W_K@Z */
220 wchar_t* CDECL MSVCP_char_traits_wchar_copy(wchar_t *dest,
221 const wchar_t *src, size_t count)
223 return MSVCP_char_traits_wchar__Copy_s(dest, count, src, count);
226 /* ?find@?$char_traits@_W@std@@SAPB_WPB_WIAB_W@Z */
227 /* ?find@?$char_traits@_W@std@@SAPEB_WPEB_W_KAEB_W@Z */
228 const wchar_t* CDECL MSVCP_char_traits_wchar_find(
229 const wchar_t *str, size_t range, const wchar_t *c)
233 for(i=0; i<range; i++)
240 /* ?_Move_s@?$char_traits@_W@std@@SAPA_WPA_WIPB_WI@Z */
241 /* ?_Move_s@?$char_traits@_W@std@@SAPEA_WPEA_W_KPEB_W1@Z */
242 wchar_t* CDECL MSVCP_char_traits_wchar__Move_s(wchar_t *dest,
243 size_t size, const wchar_t *src, size_t count)
245 if(!dest || !src || size<count) {
248 _invalid_parameter(NULL, NULL, NULL, 0, 0);
252 return memmove(dest, src, sizeof(WCHAR[count]));
255 /* ?move@?$char_traits@_W@std@@SAPA_WPA_WPB_WI@Z */
256 /* ?move@?$char_traits@_W@std@@SAPEA_WPEA_WPEB_W_K@Z */
257 wchar_t* CDECL MSVCP_char_traits_wchar_move(wchar_t *dest,
258 const wchar_t *src, size_t count)
260 return MSVCP_char_traits_wchar__Move_s(dest, count, src, count);
263 /* ?assign@?$char_traits@_W@std@@SAPA_WPA_WI_W@Z */
264 /* ?assign@?$char_traits@_W@std@@SAPEA_WPEA_W_K_W@Z */
265 wchar_t* CDECL MSVCP_char_traits_wchar_assignn(wchar_t *str,
266 size_t num, wchar_t c)
276 /* ?to_char_type@?$char_traits@_W@std@@SA_WABG@Z */
277 /* ?to_char_type@?$char_traits@_W@std@@SA_WAEBG@Z */
278 wchar_t CDECL MSVCP_char_traits_wchar_to_char_type(const unsigned short *i)
283 /* ?to_int_type@?$char_traits@_W@std@@SAGAB_W@Z */
284 /* ?to_int_type@?$char_traits@_W@std@@SAGAEB_W@Z */
285 unsigned short CDECL MSVCP_char_traits_wchar_to_int_type(const wchar_t *ch)
290 /* ?eq_int_type@?$char_traits@_W@std@@SA_NABG0@Z */
291 /* ?eq_int_type@?$char_traits@_W@std@@SA_NAEBG0@Z */
292 MSVCP_BOOL CDECL MSVCP_char_traits_wchar_eq_int_tpe(const unsigned short *i1,
293 const unsigned short *i2)
298 /* ?eof@?$char_traits@_W@std@@SAGXZ */
299 unsigned short CDECL MSVCP_char_traits_wchar_eof(void)
304 /* ?not_eof@?$char_traits@_W@std@@SAGABG@Z */
305 /* ?not_eof@?$char_traits@_W@std@@SAGAEBG@Z */
306 unsigned short CDECL MSVCP_char_traits_wchar_not_eof(const unsigned short *in)
308 return (*in==WEOF ? !WEOF : *in);
312 /* char_traits<unsigned short> */
313 /* ?assign@?$char_traits@G@std@@SAXAAGABG@Z */
314 void CDECL MSVCP_char_traits_short_assign(unsigned short *ch,
315 const unsigned short *assign)
320 /* ?eq@?$char_traits@G@std@@SA_NABG0@Z */
321 MSVCP_BOOL CDECL MSVCP_char_traits_short_eq(const unsigned short *ch1,
322 const unsigned short *ch2)
327 /* ?lt@?$char_traits@G@std@@SA_NABG0@Z */
328 MSVCP_BOOL CDECL MSVCP_char_traits_short_lt(const unsigned short *ch1,
329 const unsigned short *ch2)
334 /* ?compare@?$char_traits@G@std@@SAHPBG0I@Z */
335 int CDECL MSVCP_char_traits_short_compare(const unsigned short *s1,
336 const unsigned short *s2, unsigned int count)
340 for(i=0; i<count; i++)
342 return (s1[i] < s2[i] ? -1 : 1);
347 /* ?length@?$char_traits@G@std@@SAIPBG@Z */
348 unsigned int CDECL MSVCP_char_traits_short_length(const unsigned short *str)
352 for(len=0; str[len]; len++);
357 /* ?_Copy_s@?$char_traits@G@std@@SAPAGPAGIPBGI@Z */
358 unsigned short * CDECL MSVCP_char_traits_short__Copy_s(unsigned short *dest,
359 unsigned int size, const unsigned short *src, unsigned int count)
362 _invalid_parameter(NULL, NULL, NULL, 0, 0);
366 return memcpy(dest, src, sizeof(unsigned short[count]));
369 /* ?copy@?$char_traits@G@std@@SAPAGPAGPBGI@Z */
370 unsigned short* CDECL MSVCP_char_traits_short_copy(unsigned short *dest,
371 const unsigned short *src, unsigned int count)
373 return MSVCP_char_traits_short__Copy_s(dest, count, src, count);
376 /* ?find@?$char_traits@G@std@@SAPBGPBGIABG@Z */
377 const unsigned short* CDECL MSVCP_char_traits_short_find(
378 const unsigned short *str, unsigned int range, const unsigned short *c)
382 for(i=0; i<range; i++)
389 /* ?_Move_s@?$char_traits@G@std@@SAPAGPAGIPBGI@Z */
390 unsigned short* CDECL MSVCP_char_traits_short__Move_s(unsigned short *dest,
391 unsigned int size, const unsigned short *src, unsigned int count)
394 _invalid_parameter(NULL, NULL, NULL, 0, 0);
398 return memmove(dest, src, sizeof(unsigned short[count]));
401 /* ?move@?$char_traits@G@std@@SAPAGPAGPBGI@Z */
402 unsigned short* CDECL MSVCP_char_traits_short_move(unsigned short *dest,
403 const unsigned short *src, unsigned int count)
405 return MSVCP_char_traits_short__Move_s(dest, count, src, count);
408 /* ?assign@?$char_traits@G@std@@SAPAGPAGIG@Z */
409 unsigned short* CDECL MSVCP_char_traits_short_assignn(unsigned short *str,
410 unsigned int num, unsigned short c)
420 /* ?to_char_type@?$char_traits@G@std@@SAGABG@Z */
421 unsigned short CDECL MSVCP_char_traits_short_to_char_type(const unsigned short *i)
426 /* ?to_int_type@?$char_traits@G@std@@SAGABG@Z */
427 unsigned short CDECL MSVCP_char_traits_short_to_int_type(const unsigned short *ch)
432 /* ?eq_int_type@?$char_traits@G@std@@SA_NABG0@Z */
433 MSVCP_BOOL CDECL MSVCP_char_traits_short_eq_int_type(unsigned short *i1,
439 /* ?eof@?$char_traits@G@std@@SAGXZ */
440 unsigned short CDECL MSVCP_char_traits_short_eof(void)
445 /* ?not_eof@?$char_traits@G@std@@SAGABG@Z */
446 unsigned short CDECL MSVCP_char_traits_short_not_eof(const unsigned short *in)
448 return (*in==(unsigned short)-1 ? 0 : *in);