configure: Print a warning when prelink isn't found.
[wine/hramrach.git] / dlls / msvcp90 / string.c
blob07719034d7f0cc7faf5977d851197904b815a635
1 /*
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
19 #include "config.h"
21 #include <stdarg.h>
23 #include "msvcp90.h"
24 #include "stdio.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcp90);
31 /* char_traits<char> */
32 /* ?assign@?$char_traits@D@std@@SAXAADABD@Z */
33 /* ?assign@?$char_traits@D@std@@SAXAEADAEBD@Z */
34 void CDECL MSVCP_char_traits_char_assign(char *ch, const char *assign)
36 *ch = *assign;
39 /* ?eq@?$char_traits@D@std@@SA_NABD0@Z */
40 /* ?eq@?$char_traits@D@std@@SA_NAEBD0@Z */
41 MSVCP_BOOL CDECL MSVCP_char_traits_char_eq(const char *ch1, const char *ch2)
43 return *ch1 == *ch2;
46 /* ?lt@?$char_traits@D@std@@SA_NABD0@Z */
47 /* ?lt@?$char_traits@D@std@@SA_NAEBD0@Z */
48 MSVCP_BOOL CDECL MSVCP_char_traits_lt(const char *ch1, const char *ch2)
50 return *ch1 < *ch2;
53 /* ?compare@?$char_traits@D@std@@SAHPBD0I@Z */
54 /* ?compare@?$char_traits@D@std@@SAHPEBD0_K@Z */
55 int CDECL MSVCP_char_traits_char_compare(
56 const char *s1, const char *s2, size_t count)
58 int ret = memcmp(s1, s2, count);
59 return (ret>0 ? 1 : (ret<0 ? -1 : 0));
62 /* ?length@?$char_traits@D@std@@SAIPBD@Z */
63 /* ?length@?$char_traits@D@std@@SA_KPEBD@Z */
64 size_t CDECL MSVCP_char_traits_char_length(const char *str)
66 return strlen(str);
69 /* ?_Copy_s@?$char_traits@D@std@@SAPADPADIPBDI@Z */
70 /* ?_Copy_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z */
71 char* CDECL MSVCP_char_traits_char__Copy_s(char *dest,
72 size_t size, const char *src, size_t count)
74 if(!dest || !src || size<count) {
75 if(dest && size)
76 dest[0] = '\0';
77 _invalid_parameter(NULL, NULL, NULL, 0, 0);
78 return dest;
81 return memcpy(dest, src, count);
84 /* ?copy@?$char_traits@D@std@@SAPADPADPBDI@Z */
85 /* ?copy@?$char_traits@D@std@@SAPEADPEADPEBD_K@Z */
86 char* CDECL MSVCP_char_traits_char_copy(
87 char *dest, const char *src, size_t count)
89 return MSVCP_char_traits_char__Copy_s(dest, count, src, count);
92 /* ?find@?$char_traits@D@std@@SAPBDPBDIABD@Z */
93 /* ?find@?$char_traits@D@std@@SAPEBDPEBD_KAEBD@Z */
94 const char * CDECL MSVCP_char_traits_char_find(
95 const char *str, size_t range, const char *c)
97 return memchr(str, *c, range);
100 /* ?_Move_s@?$char_traits@D@std@@SAPADPADIPBDI@Z */
101 /* ?_Move_s@?$char_traits@D@std@@SAPEADPEAD_KPEBD1@Z */
102 char* CDECL MSVCP_char_traits_char__Move_s(char *dest,
103 size_t size, const char *src, size_t count)
105 if(!dest || !src || size<count) {
106 if(dest && size)
107 dest[0] = '\0';
108 _invalid_parameter(NULL, NULL, NULL, 0, 0);
109 return dest;
112 return memmove(dest, src, count);
115 /* ?move@?$char_traits@D@std@@SAPADPADPBDI@Z */
116 /* ?move@?$char_traits@D@std@@SAPEADPEADPEBD_K@Z */
117 char* CDECL MSVCP_char_traits_char_move(
118 char *dest, const char *src, size_t count)
120 return MSVCP_char_traits_char__Move_s(dest, count, src, count);
123 /* ?assign@?$char_traits@D@std@@SAPADPADID@Z */
124 /* ?assign@?$char_traits@D@std@@SAPEADPEAD_KD@Z */
125 char* CDECL MSVCP_char_traits_char_assignn(char *str, size_t num, char c)
127 return memset(str, c, num);
130 /* ?to_char_type@?$char_traits@D@std@@SADABH@Z */
131 /* ?to_char_type@?$char_traits@D@std@@SADAEBH@Z */
132 char CDECL MSVCP_char_traits_char_to_char_type(const int *i)
134 return (char)*i;
137 /* ?to_int_type@?$char_traits@D@std@@SAHABD@Z */
138 /* ?to_int_type@?$char_traits@D@std@@SAHAEBD@Z */
139 int CDECL MSVCP_char_traits_char_to_int_type(const char *ch)
141 return (int)*ch;
144 /* ?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z */
145 /* ?eq_int_type@?$char_traits@D@std@@SA_NAEBH0@Z */
146 MSVCP_BOOL CDECL MSVCP_char_traits_char_eq_int_type(const int *i1, const int *i2)
148 return *i1 == *i2;
151 /* ?eof@?$char_traits@D@std@@SAHXZ */
152 int CDECL MSVCP_char_traits_char_eof(void)
154 return EOF;
157 /* ?not_eof@?$char_traits@D@std@@SAHABH@Z */
158 /* ?not_eof@?$char_traits@D@std@@SAHAEBH@Z */
159 int CDECL MSVCP_char_traits_char_not_eof(int *in)
161 return (*in==EOF ? !EOF : *in);
165 /* char_traits<wchar_t> */
166 /* ?assign@?$char_traits@_W@std@@SAXAA_WAB_W@Z */
167 /* ?assign@?$char_traits@_W@std@@SAXAEA_WAEB_W@Z */
168 void CDECL MSVCP_char_traits_wchar_assign(wchar_t *ch,
169 const wchar_t *assign)
171 *ch = *assign;
174 /* ?eq@?$char_traits@_W@std@@SA_NAB_W0@Z */
175 /* ?eq@?$char_traits@_W@std@@SA_NAEB_W0@Z */
176 MSVCP_BOOL CDECL MSVCP_char_traits_wchar_eq(wchar_t *ch1, wchar_t *ch2)
178 return *ch1 == *ch2;
181 /* ?lt@?$char_traits@_W@std@@SA_NAB_W0@Z */
182 /* ?lt@?$char_traits@_W@std@@SA_NAEB_W0@Z */
183 MSVCP_BOOL CDECL MSVCP_char_traits_wchar_lt(const wchar_t *ch1,
184 const wchar_t *ch2)
186 return *ch1 < *ch2;
189 /* ?compare@?$char_traits@_W@std@@SAHPB_W0I@Z */
190 /* ?compare@?$char_traits@_W@std@@SAHPEB_W0_K@Z */
191 int CDECL MSVCP_char_traits_wchar_compare(const wchar_t *s1,
192 const wchar_t *s2, size_t count)
194 int ret = memcmp(s1, s2, sizeof(wchar_t[count]));
195 return (ret>0 ? 1 : (ret<0 ? -1 : 0));
198 /* ?length@?$char_traits@_W@std@@SAIPB_W@Z */
199 /* ?length@?$char_traits@_W@std@@SA_KPEB_W@Z */
200 size_t CDECL MSVCP_char_traits_wchar_length(const wchar_t *str)
202 return wcslen((WCHAR*)str);
205 /* ?_Copy_s@?$char_traits@_W@std@@SAPA_WPA_WIPB_WI@Z */
206 /* ?_Copy_s@?$char_traits@_W@std@@SAPEA_WPEA_W_KPEB_W1@Z */
207 wchar_t* CDECL MSVCP_char_traits_wchar__Copy_s(wchar_t *dest,
208 size_t size, const wchar_t *src, size_t count)
210 if(!dest || !src || size<count) {
211 if(dest && size)
212 dest[0] = '\0';
213 _invalid_parameter(NULL, NULL, NULL, 0, 0);
214 return dest;
217 return memcpy(dest, src, sizeof(wchar_t[count]));
220 /* ?copy@?$char_traits@_W@std@@SAPA_WPA_WPB_WI@Z */
221 /* ?copy@?$char_traits@_W@std@@SAPEA_WPEA_WPEB_W_K@Z */
222 wchar_t* CDECL MSVCP_char_traits_wchar_copy(wchar_t *dest,
223 const wchar_t *src, size_t count)
225 return MSVCP_char_traits_wchar__Copy_s(dest, count, src, count);
228 /* ?find@?$char_traits@_W@std@@SAPB_WPB_WIAB_W@Z */
229 /* ?find@?$char_traits@_W@std@@SAPEB_WPEB_W_KAEB_W@Z */
230 const wchar_t* CDECL MSVCP_char_traits_wchar_find(
231 const wchar_t *str, size_t range, const wchar_t *c)
233 size_t i=0;
235 for(i=0; i<range; i++)
236 if(str[i] == *c)
237 return str+i;
239 return NULL;
242 /* ?_Move_s@?$char_traits@_W@std@@SAPA_WPA_WIPB_WI@Z */
243 /* ?_Move_s@?$char_traits@_W@std@@SAPEA_WPEA_W_KPEB_W1@Z */
244 wchar_t* CDECL MSVCP_char_traits_wchar__Move_s(wchar_t *dest,
245 size_t size, const wchar_t *src, size_t count)
247 if(!dest || !src || size<count) {
248 if(dest && size)
249 dest[0] = '\0';
250 _invalid_parameter(NULL, NULL, NULL, 0, 0);
251 return dest;
254 return memmove(dest, src, sizeof(WCHAR[count]));
257 /* ?move@?$char_traits@_W@std@@SAPA_WPA_WPB_WI@Z */
258 /* ?move@?$char_traits@_W@std@@SAPEA_WPEA_WPEB_W_K@Z */
259 wchar_t* CDECL MSVCP_char_traits_wchar_move(wchar_t *dest,
260 const wchar_t *src, size_t count)
262 return MSVCP_char_traits_wchar__Move_s(dest, count, src, count);
265 /* ?assign@?$char_traits@_W@std@@SAPA_WPA_WI_W@Z */
266 /* ?assign@?$char_traits@_W@std@@SAPEA_WPEA_W_K_W@Z */
267 wchar_t* CDECL MSVCP_char_traits_wchar_assignn(wchar_t *str,
268 size_t num, wchar_t c)
270 size_t i;
272 for(i=0; i<num; i++)
273 str[i] = c;
275 return str;
278 /* ?to_char_type@?$char_traits@_W@std@@SA_WABG@Z */
279 /* ?to_char_type@?$char_traits@_W@std@@SA_WAEBG@Z */
280 wchar_t CDECL MSVCP_char_traits_wchar_to_char_type(const unsigned short *i)
282 return *i;
285 /* ?to_int_type@?$char_traits@_W@std@@SAGAB_W@Z */
286 /* ?to_int_type@?$char_traits@_W@std@@SAGAEB_W@Z */
287 unsigned short CDECL MSVCP_char_traits_wchar_to_int_type(const wchar_t *ch)
289 return *ch;
292 /* ?eq_int_type@?$char_traits@_W@std@@SA_NABG0@Z */
293 /* ?eq_int_type@?$char_traits@_W@std@@SA_NAEBG0@Z */
294 MSVCP_BOOL CDECL MSVCP_char_traits_wchar_eq_int_tpe(const unsigned short *i1,
295 const unsigned short *i2)
297 return *i1 == *i2;
300 /* ?eof@?$char_traits@_W@std@@SAGXZ */
301 unsigned short CDECL MSVCP_char_traits_wchar_eof(void)
303 return WEOF;
306 /* ?not_eof@?$char_traits@_W@std@@SAGABG@Z */
307 /* ?not_eof@?$char_traits@_W@std@@SAGAEBG@Z */
308 unsigned short CDECL MSVCP_char_traits_wchar_not_eof(const unsigned short *in)
310 return (*in==WEOF ? !WEOF : *in);
314 /* char_traits<unsigned short> */
315 /* ?assign@?$char_traits@G@std@@SAXAAGABG@Z */
316 /* ?assign@?$char_traits@G@std@@SAXAEAGAEBG@Z */
317 void CDECL MSVCP_char_traits_short_assign(unsigned short *ch,
318 const unsigned short *assign)
320 *ch = *assign;
323 /* ?eq@?$char_traits@G@std@@SA_NABG0@Z */
324 /* ?eq@?$char_traits@G@std@@SA_NAEBG0@Z */
325 MSVCP_BOOL CDECL MSVCP_char_traits_short_eq(const unsigned short *ch1,
326 const unsigned short *ch2)
328 return *ch1 == *ch2;
331 /* ?lt@?$char_traits@G@std@@SA_NABG0@Z */
332 /* ?lt@?$char_traits@G@std@@SA_NAEBG0@Z */
333 MSVCP_BOOL CDECL MSVCP_char_traits_short_lt(const unsigned short *ch1,
334 const unsigned short *ch2)
336 return *ch1 < *ch2;
339 /* ?compare@?$char_traits@G@std@@SAHPBG0I@Z */
340 /* ?compare@?$char_traits@G@std@@SAHPEBG0_K@Z */
341 int CDECL MSVCP_char_traits_short_compare(const unsigned short *s1,
342 const unsigned short *s2, size_t count)
344 size_t i;
346 for(i=0; i<count; i++)
347 if(s1[i] != s2[i])
348 return (s1[i] < s2[i] ? -1 : 1);
350 return 0;
353 /* ?length@?$char_traits@G@std@@SAIPBG@Z */
354 /* ?length@?$char_traits@G@std@@SA_KPEBG@Z */
355 size_t CDECL MSVCP_char_traits_short_length(const unsigned short *str)
357 size_t len;
359 for(len=0; str[len]; len++);
361 return len;
364 /* ?_Copy_s@?$char_traits@G@std@@SAPAGPAGIPBGI@Z */
365 /* ?_Copy_s@?$char_traits@G@std@@SAPEAGPEAG_KPEBG1@Z */
366 unsigned short * CDECL MSVCP_char_traits_short__Copy_s(unsigned short *dest,
367 size_t size, const unsigned short *src, size_t count)
369 if(size<count) {
370 _invalid_parameter(NULL, NULL, NULL, 0, 0);
371 return dest;
374 return memcpy(dest, src, sizeof(unsigned short[count]));
377 /* ?copy@?$char_traits@G@std@@SAPAGPAGPBGI@Z */
378 /* ?copy@?$char_traits@G@std@@SAPEAGPEAGPEBG_K@Z */
379 unsigned short* CDECL MSVCP_char_traits_short_copy(unsigned short *dest,
380 const unsigned short *src, size_t count)
382 return MSVCP_char_traits_short__Copy_s(dest, count, src, count);
385 /* ?find@?$char_traits@G@std@@SAPBGPBGIABG@Z */
386 /* ?find@?$char_traits@G@std@@SAPEBGPEBG_KAEBG@Z */
387 const unsigned short* CDECL MSVCP_char_traits_short_find(
388 const unsigned short *str, size_t range, const unsigned short *c)
390 size_t i;
392 for(i=0; i<range; i++)
393 if(str[i] == *c)
394 return str+i;
396 return NULL;
399 /* ?_Move_s@?$char_traits@G@std@@SAPAGPAGIPBGI@Z */
400 /* ?_Move_s@?$char_traits@G@std@@SAPEAGPEAG_KPEBG1@Z */
401 unsigned short* CDECL MSVCP_char_traits_short__Move_s(unsigned short *dest,
402 size_t size, const unsigned short *src, size_t count)
404 if(size<count) {
405 _invalid_parameter(NULL, NULL, NULL, 0, 0);
406 return dest;
409 return memmove(dest, src, sizeof(unsigned short[count]));
412 /* ?move@?$char_traits@G@std@@SAPAGPAGPBGI@Z */
413 /* ?move@?$char_traits@G@std@@SAPEAGPEAGPEBG_K@Z */
414 unsigned short* CDECL MSVCP_char_traits_short_move(unsigned short *dest,
415 const unsigned short *src, size_t count)
417 return MSVCP_char_traits_short__Move_s(dest, count, src, count);
420 /* ?assign@?$char_traits@G@std@@SAPAGPAGIG@Z */
421 /* ?assign@?$char_traits@G@std@@SAPEAGPEAG_KG@Z */
422 unsigned short* CDECL MSVCP_char_traits_short_assignn(unsigned short *str,
423 size_t num, unsigned short c)
425 size_t i;
427 for(i=0; i<num; i++)
428 str[i] = c;
430 return str;
433 /* ?to_char_type@?$char_traits@G@std@@SAGABG@Z */
434 /* ?to_char_type@?$char_traits@G@std@@SAGAEBG@Z */
435 unsigned short CDECL MSVCP_char_traits_short_to_char_type(const unsigned short *i)
437 return *i;
440 /* ?to_int_type@?$char_traits@G@std@@SAGABG@Z */
441 /* ?to_int_type@?$char_traits@G@std@@SAGAEBG@Z */
442 unsigned short CDECL MSVCP_char_traits_short_to_int_type(const unsigned short *ch)
444 return *ch;
447 /* ?eq_int_type@?$char_traits@G@std@@SA_NABG0@Z */
448 /* ?eq_int_type@?$char_traits@G@std@@SA_NAEBG0@Z */
449 MSVCP_BOOL CDECL MSVCP_char_traits_short_eq_int_type(unsigned short *i1,
450 unsigned short *i2)
452 return *i1 == *i2;
455 /* ?eof@?$char_traits@G@std@@SAGXZ */
456 unsigned short CDECL MSVCP_char_traits_short_eof(void)
458 return -1;
461 /* ?not_eof@?$char_traits@G@std@@SAGABG@Z */
462 /* ?not_eof@?$char_traits@G@std@@SAGAEBG@Z */
463 unsigned short CDECL MSVCP_char_traits_short_not_eof(const unsigned short *in)
465 return (*in==(unsigned short)-1 ? 0 : *in);
469 /* _String_base */
470 /* ?_Xlen@_String_base@std@@SAXXZ */
471 void CDECL MSVCP__String_base_Xlen(void)
473 static const char msg[] = "string too long";
475 TRACE("\n");
476 throw_exception(EXCEPTION_LENGTH_ERROR, msg);
479 /* ?_Xran@_String_base@std@@SAXXZ */
480 void CDECL MSVCP__String_base_Xran(void)
482 static const char msg[] = "invalid string position";
484 TRACE("\n");
485 throw_exception(EXCEPTION_OUT_OF_RANGE, msg);
488 /* ?_Xinvarg@_String_base@std@@SAXXZ */
489 void CDECL MSVCP__String_base_Xinvarg(void)
491 static const char msg[] = "invalid string argument";
493 TRACE("\n");
494 throw_exception(EXCEPTION_INVALID_ARGUMENT, msg);
498 /* basic_string<char, char_traits<char>, allocator<char>> */
499 /* ?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2IB */
500 const size_t MSVCP_basic_string_char_npos = -1;
502 /* Internal: basic_string_char_ptr - return pointer to stored string */
503 static char* basic_string_char_ptr(basic_string_char *this)
505 if(this->res == BUF_SIZE_CHAR-1)
506 return this->data.buf;
507 return this->data.ptr;
510 /* Internal: basic_string_char_const_ptr - returns const pointer to stored string */
511 static const char* basic_string_char_const_ptr(const basic_string_char *this)
513 if(this->res == BUF_SIZE_CHAR-1)
514 return this->data.buf;
515 return this->data.ptr;
518 /* Internal: basic_string_char_eos - sets string length, puts '\0' on the end */
519 static void basic_string_char_eos(basic_string_char *this, size_t len)
521 static const char nullbyte = '\0';
523 this->size = len;
524 MSVCP_char_traits_char_assign(basic_string_char_ptr(this)+len, &nullbyte);
527 /* Internal: basic_string_char_inside - checks if given pointer points inside stored string */
528 static MSVCP_BOOL basic_string_char_inside(
529 basic_string_char *this, const char *ptr)
531 char *cstr = basic_string_char_ptr(this);
533 return (ptr<cstr || ptr>=cstr+this->size) ? FALSE : TRUE;
536 /* Internal: basic_string_char_tidy - initialize basic_string buffer, deallocates data */
537 /* Caution: new_size have to be smaller than BUF_SIZE_CHAR */
538 static void basic_string_char_tidy(basic_string_char *this,
539 MSVCP_BOOL built, int new_size)
541 if(built && BUF_SIZE_CHAR<=this->res) {
542 char *ptr = this->data.ptr;
544 if(new_size > 0)
545 MSVCP_char_traits_char__Copy_s(this->data.buf, BUF_SIZE_CHAR, ptr, new_size);
546 MSVCP_allocator_char_deallocate(this->allocator, ptr, this->res+1);
549 this->res = BUF_SIZE_CHAR-1;
550 basic_string_char_eos(this, new_size);
553 /* Internal: basic_string_char_grow - changes size of internal buffer */
554 static MSVCP_BOOL basic_string_char_grow(
555 basic_string_char *this, size_t new_size, MSVCP_BOOL trim)
557 if(this->res < new_size) {
558 size_t new_res = new_size;
559 char *ptr;
561 new_res |= 0xf;
563 if(new_res/3 < this->res/2)
564 new_res = this->res + this->res/2;
566 ptr = MSVCP_allocator_char_allocate(this->allocator, new_res);
567 if(!ptr)
568 ptr = MSVCP_allocator_char_allocate(this->allocator, new_size+1);
569 else
570 new_size = new_res;
571 if(!ptr) {
572 ERR("Out of memory\n");
573 basic_string_char_tidy(this, TRUE, 0);
574 return FALSE;
577 MSVCP_char_traits_char__Copy_s(ptr, new_size,
578 basic_string_char_ptr(this), this->size);
579 basic_string_char_tidy(this, TRUE, 0);
580 this->data.ptr = ptr;
581 this->res = new_size;
582 basic_string_char_eos(this, this->size);
583 } else if(trim && new_size < BUF_SIZE_CHAR)
584 basic_string_char_tidy(this, TRUE,
585 new_size<this->size ? new_size : this->size);
586 else if(new_size == 0)
587 basic_string_char_eos(this, 0);
589 return (new_size>0);
592 /* ?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z */
593 /* ?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV12@_K0@Z */
594 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_erase, 12)
595 basic_string_char* __stdcall MSVCP_basic_string_char_erase(
596 basic_string_char *this, size_t pos, size_t len)
598 TRACE("%p %d %d\n", this, pos, len);
600 if(pos > this->size) {
601 MSVCP__String_base_Xran();
602 return NULL;
605 if(len > this->size-pos)
606 len = this->size-pos;
608 if(len) {
609 MSVCP_char_traits_char__Move_s(basic_string_char_ptr(this)+pos,
610 this->res-pos, basic_string_char_ptr(this)+pos+len,
611 this->size-pos-len);
612 basic_string_char_eos(this, this->size-len);
615 return this;
618 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z */
619 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV12@AEBV12@_K1@Z */
620 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_assign_substr, 16)
621 basic_string_char* __stdcall MSVCP_basic_string_char_assign_substr(
622 basic_string_char *this, const basic_string_char *assign,
623 size_t pos, size_t len)
625 TRACE("%p %p %d %d\n", this, assign, pos, len);
627 if(assign->size < pos) {
628 MSVCP__String_base_Xran();
629 return NULL;
632 if(len > assign->size-pos)
633 len = assign->size-pos;
635 if(this == assign) {
636 MSVCP_basic_string_char_erase(this, pos+len, MSVCP_basic_string_char_npos);
637 MSVCP_basic_string_char_erase(this, 0, pos);
638 } else if(basic_string_char_grow(this, len, FALSE)) {
639 MSVCP_char_traits_char__Copy_s(basic_string_char_ptr(this),
640 this->res, basic_string_char_const_ptr(assign)+pos, len);
641 basic_string_char_eos(this, len);
644 return this;
647 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@@Z */
648 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV12@AEBV12@@Z */
649 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_assign, 8)
650 basic_string_char* __stdcall MSVCP_basic_string_char_assign(
651 basic_string_char *this, const basic_string_char *assign)
653 return MSVCP_basic_string_char_assign_substr(this, assign,
654 0, MSVCP_basic_string_char_npos);
657 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI@Z */
658 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV12@PEBD_K@Z */
659 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_assign_cstr_len, 12)
660 basic_string_char* __stdcall MSVCP_basic_string_char_assign_cstr_len(
661 basic_string_char *this, const char *str, size_t len)
663 TRACE("%p %s %d\n", this, debugstr_a(str), len);
665 if(basic_string_char_inside(this, str))
666 return MSVCP_basic_string_char_assign_substr(this, this,
667 str-basic_string_char_ptr(this), len);
668 else if(basic_string_char_grow(this, len, FALSE)) {
669 MSVCP_char_traits_char__Copy_s(basic_string_char_ptr(this),
670 this->res, str, len);
671 basic_string_char_eos(this, len);
674 return this;
677 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBD@Z */
678 /* ?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV12@PEBD@Z */
679 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_assign_cstr, 8)
680 basic_string_char* __stdcall MSVCP_basic_string_char_assign_cstr(
681 basic_string_char *this, const char *str)
683 return MSVCP_basic_string_char_assign_cstr_len(this, str,
684 MSVCP_char_traits_char_length(str));
687 /* ?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ */
688 /* ?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ */
689 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_c_str, 4)
690 const char* __stdcall MSVCP_basic_string_char_c_str(basic_string_char *this)
692 TRACE("%p\n", this);
693 return basic_string_char_const_ptr(this);
696 /* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ */
697 /* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ */
698 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_ctor, 4)
699 basic_string_char* __stdcall MSVCP_basic_string_char_ctor(basic_string_char *this)
701 TRACE("%p\n", this);
703 basic_string_char_tidy(this, FALSE, 0);
704 return this;
707 /* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z */
708 /* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV01@@Z */
709 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_copy_ctor, 8)
710 basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(
711 basic_string_char *this, const basic_string_char *copy)
713 TRACE("%p %p\n", this, copy);
715 basic_string_char_tidy(this, FALSE, 0);
716 MSVCP_basic_string_char_assign(this, copy);
717 return this;
720 /* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z */
721 /* ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@PEBD@Z */
722 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_ctor_cstr, 8)
723 basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(
724 basic_string_char *this, const char *str)
726 TRACE("%p %s\n", this, debugstr_a(str));
728 basic_string_char_tidy(this, FALSE, 0);
729 MSVCP_basic_string_char_assign_cstr(this, str);
730 return this;
733 /* ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ */
734 /* ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ */
735 DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_dtor, 4)
736 void __stdcall MSVCP_basic_string_char_dtor(basic_string_char *this)
738 TRACE("%p\n", this);
739 basic_string_char_tidy(this, TRUE, 0);