compilation fix for !wxUSE_PRINTF_POS_PARAMS
[wxWidgets.git] / include / wx / wxcrt.h
1 /*
2 * Name: wx/wxcrt.h
3 * Purpose: Type-safe ANSI and Unicode builds compatible wrappers for
4 * CRT functions
5 * Author: Joel Farley, Ove Kåven
6 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
7 * Created: 1998/06/12
8 * RCS-ID: $Id$
9 * Copyright: (c) 1998-2006 wxWidgets dev team
10 * Licence: wxWindows licence
11 */
12
13 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
14
15 #ifndef _WX_WXCRT_H_
16 #define _WX_WXCRT_H_
17
18 #include "wx/chartype.h"
19
20 #ifdef __cplusplus
21 #include "wx/strvararg.h"
22 #else
23 /* make the file compile without doing anything in C code: */
24 #define WX_DEFINE_VARARG_FUNC(rettype, name, impl)
25 #endif
26
27 #include <stdio.h> /* we use FILE below */
28
29 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
30 char *strtok_r(char *, const char *, char **);
31 #endif
32
33
34 /*
35 Standard headers we need here.
36
37 NB: don't include any wxWidgets headers here because almost all of them include
38 this one!
39 */
40
41 /* Required for wxPrintf() etc */
42 #include <stdarg.h>
43
44 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
45 /* and VC++ for Windows CE don't provide it */
46 #if defined(__VISUALC__) && __VISUALC__ >= 1400
47 #define wxStrdupA _strdup
48 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
49 /* use #define, not inline wrapper, as it is tested with #ifndef below */
50 #define wxStrdupA strdup
51 #endif
52
53 #if defined(__MWERKS__)
54 /* Metrowerks only has wide char support for OS X >= 10.3 */
55 #if !defined(__DARWIN__) || \
56 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
57 #define wxHAVE_MWERKS_UNICODE
58 #endif
59
60 #ifdef wxHAVE_MWERKS_UNICODE
61 #define HAVE_WPRINTF 1
62 #define HAVE_WCSRTOMBS 1
63 #define HAVE_VSWPRINTF 1
64 #endif
65 #endif /* __MWERKS__ */
66
67 #ifdef wxHAVE_TCHAR_SUPPORT
68 /* we surely have wchar_t if we have TCHAR have wcslen() */
69 #ifndef HAVE_WCSLEN
70 #define HAVE_WCSLEN
71 #endif
72 #endif /* wxHAVE_TCHAR_SUPPORT */
73
74 /*
75 define wxFoo() function for each standard foo() function whose signature
76 (exceptionally including the return type) includes any mention of char:
77 wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
78 the same signature but with char replaced by wxChar which allows us to
79 use it in Unicode build as well
80 */
81
82 #ifdef wxHAVE_TCHAR_SUPPORT
83 #include <ctype.h>
84
85 #if defined(__WATCOMC__) && defined(UNICODE)
86 #define WXWCHAR_T_CAST(c) (wint_t)(c)
87 #else
88 #define WXWCHAR_T_CAST(c) c
89 #endif
90
91 /* ctype.h functions */
92 #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
93 #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
94 #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
95 #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
96 #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
97 #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
98 #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
99 #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
100 #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
101 #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
102 #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
103
104 /*
105 There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
106 signed chars < 0, so "fix" it here.
107 */
108 #define wxTolower(c) _totlower((wxUChar)(wxChar)(c))
109 #define wxToupper(c) _totupper((wxUChar)(wxChar)(c))
110
111 /* locale.h functons */
112 #define wxSetlocale _tsetlocale
113
114 /* string.h functions */
115 #define wxStrcat _tcscat
116 #define wxStrchr _tcschr
117 #define wxStrcmp _tcscmp
118 #define wxStrcoll _tcscoll
119 #define wxStrcpy _tcscpy
120 #define wxStrcspn _tcscspn
121 #define wxStrdupW _wcsdup /* notice the 'W'! */
122 #define wxStrftime _tcsftime
123 #define wxStricmp _tcsicmp
124 #define wxStrnicmp _tcsnicmp
125 #define wxStrlen_ _tcslen /* used in wxStrlen inline function */
126 #define wxStrncat _tcsncat
127 #define wxStrncmp _tcsncmp
128 #define wxStrncpy _tcsncpy
129 #define wxStrpbrk _tcspbrk
130 #define wxStrrchr _tcsrchr
131 #define wxStrspn _tcsspn
132 #define wxStrstr _tcsstr
133 #define wxStrtod _tcstod
134 #define wxStrtol _tcstol
135 #define wxStrtoul _tcstoul
136 #ifdef __VISUALC__
137 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
138 #define wxStrtoll _tcstoi64
139 #define wxStrtoull _tcstoui64
140 #endif /* VC++ 7+ */
141 #endif
142 #define wxStrxfrm _tcsxfrm
143
144 /* stdio.h functions */
145 #define wxFgetc _fgettc
146 #define wxFgetchar _fgettchar
147 #define wxFgets _fgetts
148 #if wxUSE_UNICODE_MSLU
149 WXDLLIMPEXP_BASE FILE * wxMSLU__tfopen(const wxChar *name, const wxChar *mode);
150
151 #define wxFopen wxMSLU__tfopen
152 #else
153 #define wxFopen _tfopen
154 #endif
155 #define wxFputc _fputtc
156 #define wxFputchar _fputtchar
157 WX_DEFINE_VARARG_FUNC(int, wxFprintf, _ftprintf)
158 #define wxFputs _fputts
159 #define wxFreopen _tfreopen
160 #define wxFscanf _ftscanf
161 #define wxGetc _gettc
162 #define wxGetchar _gettchar
163 #define wxGets _getts
164 #define wxPerror _tperror
165 WX_DEFINE_VARARG_FUNC(int, wxPrintf, _tprintf)
166 #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
167 #define wxPutchar _puttchar
168 #define wxPuts _putts
169 #define wxScanf _tscanf
170 #if defined(__DMC__)
171 #if wxUSE_UNICODE
172 /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
173 int wxDoSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
174 WX_DEFINE_VARARG_FUNC(int, wxSprintf, wxDoSprintf)
175 #else
176 /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
177 WX_DEFINE_VARARG_FUNC(int, wxSprintf, sprintf)
178 #endif
179 #else
180 WX_DEFINE_VARARG_FUNC(int, wxSprintf, _stprintf)
181 #endif
182
183 #define wxSscanf _stscanf
184 #define wxTmpnam _ttmpnam
185 #define wxUngetc _tungetc
186 #define wxVfprintf _vftprintf
187 #define wxVprintf _vtprintf
188 #define wxVsscanf _vstscanf
189 #define wxVsprintf _vstprintf
190
191 /* special case: these functions are missing under Win9x with Unicows so we */
192 /* have to implement them ourselves */
193 #if wxUSE_UNICODE_MSLU
194 WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, const wxChar *newname);
195 WXDLLIMPEXP_BASE int wxMSLU__tremove(const wxChar *name);
196
197 #define wxRemove wxMSLU__tremove
198 #define wxRename wxMSLU__trename
199 #else
200 #ifdef __WXWINCE__
201 /* carefully: wxRemove() must return 0 on success while DeleteFile()
202 returns 0 on error, so don't just define one as the other */
203 int wxRemove(const wxChar *path);
204 #else
205 #define wxRemove _tremove
206 #define wxRename _trename
207 #endif
208 #endif
209
210 /* stdlib.h functions */
211 #define wxAtoi _ttoi
212 #define wxAtol _ttol
213 /* #define wxAtof _tttof -- notice that there is no such thing (why?) */
214 /* there are no env vars at all under CE, so no _tgetenv neither */
215 #ifdef __WXWINCE__
216 /* can't define as inline function as this is a C file... */
217 #define wxGetenv(name) ((wxChar *)NULL)
218 #else
219 #define wxGetenv _tgetenv
220 #endif
221 #define wxSystem _tsystem
222
223 /* time.h functions */
224 #define wxAsctime _tasctime
225 #define wxCtime _tctime
226
227 #define wxMbstowcs mbstowcs
228 #define wxWcstombs wcstombs
229 #else /* !TCHAR-aware compilers */
230 /*
231 There are 2 unrelated problems with these functions under Mac:
232 a) Metrowerks MSL CRT implements them strictly in C99 sense and
233 doesn't support (very common) extension of allowing to call
234 mbstowcs(NULL, ...) which makes it pretty useless as you can't
235 know the size of the needed buffer
236 b) OS X <= 10.2 declares and even defined these functions but
237 doesn't really implement them -- they always return an error
238
239 So use our own replacements in both cases.
240 */
241 #if defined(__MWERKS__) && defined(__MSL__)
242 #define wxNEED_WX_MBSTOWCS
243 #endif
244
245 #ifdef __DARWIN__
246 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
247 #define wxNEED_WX_MBSTOWCS
248 #endif
249 #endif
250
251 #ifdef wxNEED_WX_MBSTOWCS
252 /* even though they are defined and "implemented", they are bad and just
253 stubs so we need our own - we need these even in ANSI builds!! */
254 WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t);
255 WXDLLIMPEXP_BASE size_t wxWcstombs (char *, const wchar_t *, size_t);
256 #else
257 #define wxMbstowcs mbstowcs
258 #define wxWcstombs wcstombs
259 #endif
260
261 /*
262 The system C library on Mac OS X 10.2 and below does not support
263 unicode: in other words all wide-character functions such as towupper et
264 al. do simply not exist so we need to provide our own in that context,
265 except for the wchar_t definition/typedef itself.
266
267 We need to do this for both project builder and CodeWarrior as
268 the latter uses the system C library in Mach builds for wide character
269 support, which as mentioned does not exist on 10.2 and below.
270 */
271 #if wxUSE_UNICODE && \
272 defined(__DARWIN__) && \
273 ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
274 /* we need everything! */
275 #define wxNEED_WX_STRING_H
276 #define wxNEED_WX_CTYPE_H
277
278 #define wxFgetchar(c) wxFgetc(c, stdin)
279 #define wxFputc wxPutc
280 #define wxFputchar(c) wxPutc(c, stdout)
281 #define wxGetc wxFgetc
282 #define wxGetchar(c) wxFgetc(c, stdin)
283
284 #include <stdio.h>
285
286 #define wxNEED_FGETC
287 #define wxNEED_FGETS
288 #define wxNEED_GETS
289 #define wxNEED_UNGETC
290
291 #define wxNEED_FPUTS
292 #define wxNEED_PUTS
293 #define wxNEED_PUTC
294
295 int wxFputs(const wxChar *ch, FILE *stream);
296 int wxPuts(const wxChar *ws);
297 int wxPutc(wxChar ch, FILE *stream);
298
299 #ifdef __cplusplus
300 extern "C" {
301 #endif
302 WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s);
303 #ifdef __cplusplus
304 }
305 #endif
306
307 #define wxPutchar(wch) wxPutc(wch, stdout)
308
309 #define wxNEED_PRINTF_CONVERSION
310 #define wxNEED_WX_STDIO_H
311 #define wxNEED_WX_STDLIB_H
312 #define wxNEED_WX_TIME_H
313
314 #elif wxUSE_UNICODE
315 #include <wctype.h>
316
317 /* this is probably glibc-specific */
318 #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
319 /* ctype.h functions (wctype.h) */
320 #define wxIsalnum iswalnum
321 #define wxIsalpha iswalpha
322 #define wxIscntrl iswcntrl
323 #define wxIsdigit iswdigit
324 #define wxIsgraph iswgraph
325 #define wxIslower iswlower
326 #define wxIsprint iswprint
327 #define wxIspunct iswpunct
328 #define wxIsspace iswspace
329 #define wxIsupper iswupper
330 #define wxIsxdigit iswxdigit
331
332 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
333 /* /usr/include/wctype.h incorrectly declares translations */
334 /* tables which provokes tons of compile-time warnings -- try */
335 /* to correct this */
336 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
337 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
338 #else /* !glibc 2.0 */
339 #define wxTolower towlower
340 #define wxToupper towupper
341 #endif /* gcc/!gcc */
342
343 /* string.h functions (wchar.h) */
344 #define wxStrcat wcscat
345 #define wxStrchr wcschr
346 #define wxStrcmp wcscmp
347 #define wxStrcoll wcscoll
348 #define wxStrcpy wcscpy
349 #define wxStrcspn wcscspn
350 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
351 #define wxStrncat wcsncat
352 #define wxStrncmp wcsncmp
353 #define wxStrncpy wcsncpy
354 #define wxStrpbrk wcspbrk
355 #define wxStrrchr wcsrchr
356 #define wxStrspn wcsspn
357 #define wxStrstr wcsstr
358 #define wxStrtod wcstod
359 #define wxStrtol wcstol
360 #define wxStrtoul wcstoul
361 #ifdef HAVE_WCSTOULL
362 /* assume that we have wcstoull(), which is also C99, too */
363 #define wxStrtoll wcstoll
364 #define wxStrtoull wcstoull
365 #endif /* HAVE_WCSTOULL */
366 #define wxStrxfrm wcsxfrm
367
368 #define wxFgetc fgetwc
369 #define wxFgetchar fgetwchar
370 #define wxFgets fgetws
371 #define wxFputc fputwc
372 #define wxFputchar fputwchar
373 #define wxGetc getwc
374 #define wxGetchar getwchar
375 #define wxGets getws
376 #define wxUngetc ungetwc
377
378 #ifdef HAVE_FPUTWS
379 #define wxFputs fputws
380 #else
381 #define wxNEED_FPUTS
382 #include <stdio.h>
383 int wxFputs(const wxChar *ch, FILE *stream);
384 #endif
385
386 #ifdef HAVE_WPUTC
387 #define wxPutc wputc
388 #else
389 #define wxNEED_PUTC
390 #include <stdio.h>
391 int wxPutc(wxChar ch, FILE *stream);
392 #endif
393
394 #ifdef HAVE_WPUTCHAR
395 #define wxPutchar wputchar
396 #else
397 #define wxPutchar(wch) wxPutc(wch, stdout)
398 #endif
399
400 #ifdef HAVE_PUTWS
401 #define wxPuts putws
402 #else
403 #define wxNEED_PUTS
404 int wxPuts(const wxChar *ws);
405 #endif
406
407 /* we need %s to %ls conversion for printf and scanf etc */
408 #define wxNEED_PRINTF_CONVERSION
409
410 /* glibc doesn't have wide char equivalents of the other stuff so */
411 /* use our own versions */
412 #define wxNEED_WX_STDIO_H
413 #define wxNEED_WX_STDLIB_H
414 #define wxNEED_WX_TIME_H
415 #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
416 /* ctype.h functions (wctype.h) */
417 #define wxIsalnum iswalnum
418 #define wxIsalpha iswalpha
419 #define wxIscntrl iswcntrl
420 #define wxIsdigit iswdigit
421 #define wxIsgraph iswgraph
422 #define wxIslower iswlower
423 #define wxIsprint iswprint
424 #define wxIspunct iswpunct
425 #define wxIsspace iswspace
426 #define wxIsupper iswupper
427 #define wxIsxdigit iswxdigit
428 #define wxTolower towlower
429 #define wxToupper towupper
430
431 /* string.h functions (wchar.h) */
432 #define wxStrcat wcscat
433 #define wxStrchr wcschr
434 #define wxStrcmp wcscmp
435 #define wxStrcoll wcscoll
436 #define wxStrcpy wcscpy
437 #define wxStrcspn wcscspn
438 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
439 #define wxStrncat wcsncat
440 #define wxStrncmp wcsncmp
441 #define wxStrncpy wcsncpy
442 #define wxStrpbrk wcspbrk
443 #define wxStrrchr wcsrchr
444 #define wxStrspn wcsspn
445 #define wxStrstr wcsstr
446 #define wxStrtod wcstod
447 #define wxStrtol wcstol
448 #define wxStrtoul wcstoul
449 #define wxStrxfrm wcsxfrm
450
451 #define wxFgetc fgetwc
452 #define wxFgetchar fgetwchar
453 #define wxFgets fgetws
454 #define wxFputc fputwc
455 #define wxFputchar fputwchar
456 #define wxGetc getwc
457 #define wxGetchar getwchar
458 #define wxGets getws
459 #define wxUngetc ungetwc
460
461 #define wxNEED_PRINTF_CONVERSION
462
463 #define wxPutc putwc
464 #define wxPutchar putwchar
465 #define wxFputs fputws
466
467 /* stdio.h functions */
468
469 #define wxNEED_WX_STDIO_H
470
471 /* stdlib.h functions */
472 #ifdef __MACH__
473 #define wxNEED_WX_STDLIB_H
474 #else
475 #define wxAtof watof
476 #define wxAtoi watoi
477 #define wxAtol watol
478 #define wxGetenv(a) ((wxChar*)NULL)
479 #define wxSystem(a) ((int)NULL)
480 #endif
481 /* time.h functions */
482 #define wxAsctime wasciitime
483 #define wxCtime wctime
484 /* #define wxStrftime wcsftime */
485
486 #define wxNEED_WX_TIME_H
487 #else /* !metrowerks for apple */
488 #error "Please define wide character functions for your environment"
489 #endif
490 #else /* ASCII */
491 #include <ctype.h>
492 #include <string.h>
493
494 /* ctype.h functions */
495 #define wxIsalnum isalnum
496 #define wxIsalpha isalpha
497 #define wxIscntrl iscntrl
498 #define wxIsdigit isdigit
499 #define wxIsgraph isgraph
500 #define wxIslower islower
501 #define wxIsprint isprint
502 #define wxIspunct ispunct
503 #define wxIsspace isspace
504 #define wxIsupper isupper
505 #define wxIsxdigit isxdigit
506 #define wxTolower tolower
507 #define wxToupper toupper
508
509 /* locale.h functons */
510 #define wxSetlocale setlocale
511
512 /* string.h functions */
513 #define wxStrcat strcat
514 #define wxStrchr strchr
515 #define wxStrcmp strcmp
516 #define wxStrcoll strcoll
517 #define wxStrcpy strcpy
518 #define wxStrcspn strcspn
519
520 /* wxStricmp and wxStrnicmp are defined below */
521 #define wxStrlen_ strlen /* used in wxStrlen inline function */
522 #define wxStrncat strncat
523 #define wxStrncmp strncmp
524 #define wxStrncpy strncpy
525 #define wxStrpbrk strpbrk
526 #define wxStrrchr strrchr
527 #define wxStrspn strspn
528 #define wxStrstr strstr
529 #define wxStrtod strtod
530 #ifdef HAVE_STRTOK_R
531 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
532 #endif
533 #define wxStrtol strtol
534 #define wxStrtoul strtoul
535 #ifdef HAVE_STRTOULL
536 /* assume that we have wcstoull(), which is also C99, too */
537 #define wxStrtoll strtoll
538 #define wxStrtoull strtoull
539 #endif /* HAVE_WCSTOULL */
540 #define wxStrxfrm strxfrm
541
542 /* stdio.h functions */
543 #define wxFopen fopen
544 #define wxFreopen freopen
545 #define wxRemove remove
546 #define wxRename rename
547
548 #define wxPerror perror
549 #define wxTmpnam tmpnam
550
551 #define wxFgetc fgetc
552 #define wxFgetchar fgetchar
553 #define wxFgets fgets
554 #define wxFputc fputc
555 #define wxFputs fputs
556 #define wxFputchar fputchar
557 WX_DEFINE_VARARG_FUNC(int, wxFprintf, fprintf)
558 #define wxFscanf fscanf
559 #define wxGetc getc
560 #define wxGetchar getchar
561 #define wxGets gets
562 WX_DEFINE_VARARG_FUNC(int, wxPrintf, printf)
563 #define wxPutc putc
564 #define wxPutchar putchar
565 #define wxPuts puts
566 #define wxScanf scanf
567 WX_DEFINE_VARARG_FUNC(int, wxSprintf, sprintf)
568 #define wxSscanf sscanf
569 #define wxUngetc ungetc
570 #define wxVfprintf vfprintf
571 #define wxVprintf vprintf
572 #define wxVsscanf vsscanf
573 #define wxVsprintf vsprintf
574
575 /* stdlib.h functions */
576 #define wxAtof atof
577 #define wxAtoi atoi
578 #define wxAtol atol
579 #define wxGetenv getenv
580 #define wxSystem system
581
582 /* time.h functions */
583 #define wxAsctime asctime
584 #define wxCtime ctime
585 #define wxStrftime strftime
586 #endif /* Unicode/ASCII */
587 #endif /* TCHAR-aware compilers/the others */
588
589 #ifdef wxStrtoll
590 #define wxHAS_STRTOLL
591 #endif
592
593 /*
594 various special cases
595 */
596
597 /* define wxStricmp and wxStrnicmp for various compilers */
598
599 /* note that in Unicode mode we definitely are going to need our own version */
600 #if !defined(wxStricmp) && !wxUSE_UNICODE
601 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
602 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
603 defined(__EMX__) || defined(__DJGPP__)
604 #define wxStricmp stricmp
605 #define wxStrnicmp strnicmp
606 #elif defined(__WXPALMOS__)
607 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
608 * quick hack should do until one can be written.
609 */
610 #define wxStricmp StrCaselessCompare
611 #define wxStrnicmp strnicmp
612 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
613 (defined(__MWERKS__) && defined(__INTEL__))
614 #define wxStricmp _stricmp
615 #define wxStrnicmp _strnicmp
616 #elif defined(__UNIX__) || defined(__GNUWIN32__)
617 #define wxStricmp strcasecmp
618 #define wxStrnicmp strncasecmp
619 /* #else -- use wxWidgets implementation */
620 #endif
621 #endif /* !defined(wxStricmp) */
622
623 /* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
624 /* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
625 /* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
626 #if wxUSE_WCHAR_T
627 #ifdef HAVE_WCSLEN
628 #define wxWcslen wcslen
629 #else
630 WXDLLIMPEXP_BASE size_t wxWcslen(const wchar_t *s);
631 #endif
632 #endif /* wxUSE_WCHAR_T */
633
634 #ifdef __cplusplus
635 /* checks whether the passed in pointer is NULL and if the string is empty */
636 inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
637
638 /* safe version of strlen() (returns 0 if passed NULL pointer) */
639 inline size_t wxStrlen(const wxChar *psz) { return psz ? wxStrlen_(psz) : 0; }
640 #endif
641
642 /*
643 each of strdup() and wcsdup() may or may not be available but we need both
644 of them anyhow for wx/buffer.h so we define the missing one(s) in
645 wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
646 defined -- if this is somehow not the case in some situations, please
647 correct that and not the lines here
648 */
649 #if wxUSE_UNICODE
650 #define wxStrdup wxStrdupW
651 #else
652 #define wxStrdup wxStrdupA
653 #endif
654
655 #ifdef __cplusplus
656 WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
657 #endif
658
659 /* printf() family saga */
660
661 /*
662 For some systems [v]snprintf() exists in the system libraries but not in the
663 headers, so we need to declare it ourselves to be able to use it.
664 */
665 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
666 #ifdef __cplusplus
667 extern "C"
668 #else
669 extern
670 #endif
671 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
672 #endif /* !HAVE_VSNPRINTF_DECL */
673
674 #if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL)
675 #ifdef __cplusplus
676 extern "C"
677 #else
678 extern
679 #endif
680 WXDLLIMPEXP_BASE int snprintf(char *str, size_t size, const char *format, ...);
681 #endif /* !HAVE_SNPRINTF_DECL */
682
683 /* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the
684 * same isn't done for snprintf below, the builtin wxSnprintf_ is used
685 * instead since it's already a simple wrapper */
686 #if defined __cplusplus && defined HAVE_BROKEN_VSNPRINTF_DECL
687 inline int wx_fixed_vsnprintf(char *str, size_t size, const char *format, va_list ap)
688 {
689 return vsnprintf(str, size, (char*)format, ap);
690 }
691 #endif
692
693 /*
694 MinGW MSVCRT has non-standard vswprintf() (for MSVC compatibility
695 presumably) and normally _vsnwprintf() is used instead
696 */
697 #if defined(HAVE_VSWPRINTF) && defined(__MINGW32__)
698 #undef HAVE_VSWPRINTF
699 #endif
700
701 #if wxUSE_PRINTF_POS_PARAMS
702 /*
703 The systems where vsnprintf() supports positional parameters should
704 define the HAVE_UNIX98_PRINTF symbol.
705
706 On systems which don't (e.g. Windows) we are forced to use
707 our wxVsnprintf() implementation.
708 */
709 #if defined(HAVE_UNIX98_PRINTF)
710 #if wxUSE_UNICODE
711 #ifdef HAVE_VSWPRINTF
712 #define wxVsnprintf_ vswprintf
713 #endif
714 #else /* ASCII */
715 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
716 #define wxVsnprintf_ wx_fixed_vsnprintf
717 #else
718 #define wxVsnprintf_ vsnprintf
719 #endif
720 #endif
721 #else /* !HAVE_UNIX98_PRINTF */
722 /*
723 The only compiler with positional parameters support under Windows
724 is VC++ 8.0 which provides a new xxprintf_p() functions family.
725 The 2003 PSDK includes a slightly earlier version of VC8 than the
726 main release and does not have the printf_p functions.
727 */
728 #if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__
729 #if wxUSE_UNICODE
730 #define wxVsnprintf_ _vswprintf_p
731 #else
732 #define wxVsnprintf_ _vsprintf_p
733 #endif
734 #endif
735 #endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */
736 #else /* !wxUSE_PRINTF_POS_PARAMS */
737 /*
738 We always want to define safe snprintf() function to be used instead of
739 sprintf(). Some compilers already have it (or rather vsnprintf() which
740 we really need...), otherwise we implement it using our own printf()
741 code.
742
743 We define function with a trailing underscore here because the real one
744 is a wrapper around it as explained below
745 */
746
747 /* first deal with TCHAR-aware compilers which have _vsntprintf */
748 #ifndef wxVsnprintf_
749 #if defined(__VISUALC__) || \
750 (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
751 #define wxSnprintf_ _sntprintf
752 #define wxVsnprintf_ _vsntprintf
753 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, _sntprintf)
754 #endif
755 #endif
756
757 /* if this didn't work, define it separately for Unicode and ANSI builds */
758 #ifndef wxVsnprintf_
759 #if wxUSE_UNICODE
760 #if defined(HAVE__VSNWPRINTF)
761 #define wxVsnprintf_ _vsnwprintf
762 #elif defined(HAVE_VSWPRINTF)
763 #define wxVsnprintf_ vswprintf
764 #elif defined(__WATCOMC__)
765 #define wxVsnprintf_ _vsnwprintf
766 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, _snwprintf)
767 #endif
768 #else /* ASCII */
769 /*
770 All versions of CodeWarrior supported by wxWidgets apparently
771 have both snprintf() and vsnprintf()
772 */
773 #if defined(HAVE_SNPRINTF) \
774 || defined(__MWERKS__) || defined(__WATCOMC__)
775 #ifndef HAVE_BROKEN_SNPRINTF_DECL
776 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, snprintf)
777 #endif
778 #endif
779 #if defined(HAVE_VSNPRINTF) \
780 || defined(__MWERKS__) || defined(__WATCOMC__)
781 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
782 #define wxVsnprintf_ wx_fixed_vsnprintf
783 #else
784 #define wxVsnprintf_ vsnprintf
785 #endif
786 #endif
787 #endif /* Unicode/ASCII */
788 #endif /* wxVsnprintf_ */
789 #endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */
790
791 #ifndef wxSnprintf_
792 /* no snprintf(), cook our own */
793 WXDLLIMPEXP_BASE int
794 wxDoSnprintf_(wxChar *buf, size_t len,
795 const wxChar *format, ...) ATTRIBUTE_PRINTF_3;
796 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, wxDoSnprintf_)
797 #endif
798 #ifndef wxVsnprintf_
799 /* no (suitable) vsnprintf(), cook our own */
800 WXDLLIMPEXP_BASE int
801 wxVsnprintf_(wxChar *buf, size_t len,
802 const wxChar *format, va_list argptr);
803
804 #define wxUSE_WXVSNPRINTF 1
805 #else
806 #define wxUSE_WXVSNPRINTF 0
807 #endif
808
809 /*
810 In Unicode mode we need to have all standard functions such as wprintf() and
811 so on but not all systems have them so use our own implementations in this
812 case.
813 */
814 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
815 #define wxNEED_WPRINTF
816 #endif
817
818 /*
819 More Unicode complications: although both ANSI C and C++ define a number of
820 wide character functions such as wprintf(), not all environments have them.
821 Worse, those which do have different behaviours: under Windows, %s format
822 specifier changes its meaning in Unicode build and expects a Unicode string
823 while under Unix/POSIX it still means an ASCII string even for wprintf() and
824 %ls has to be used for wide strings.
825
826 We choose to always emulate Windows behaviour as more useful for us so even
827 if we have wprintf() we still must wrap it in a non trivial wxPrintf().
828
829 */
830
831 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
832 /*
833 we need to implement all wide character printf and scanf functions
834 either because we don't have them at all or because they don't have the
835 semantics we need
836 */
837 WX_DEFINE_VARARG_FUNC(int, wxScanf, wxDoScanf)
838 int wxDoScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
839
840 WX_DEFINE_VARARG_FUNC(int, wxSscanf, wxDoSscanf)
841 int wxDoSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
842
843 WX_DEFINE_VARARG_FUNC(int, wxFscanf, wxDoFscanf)
844 int wxDoFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
845
846 WX_DEFINE_VARARG_FUNC(int, wxPrintf, wxDoPrintf)
847 int wxDoPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
848
849 WX_DEFINE_VARARG_FUNC(int, wxSprintf, wxDoSprintf)
850 int wxDoSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
851
852 WX_DEFINE_VARARG_FUNC(int, wxFprintf, wxDoFprintf)
853 int wxDoFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
854
855 int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
856 int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
857 int wxVprintf( const wxChar *format, va_list ap );
858 int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
859 #endif /* wxNEED_PRINTF_CONVERSION */
860
861 /* these 2 can be simply mapped to the versions with underscore at the end */
862 /* if we don't have to do the conversion */
863 /*
864 However, if we don't have any vswprintf() at all we don't need to redefine
865 anything as our own wxVsnprintf_() already behaves as needed.
866 */
867 #if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_)
868 WX_DEFINE_VARARG_FUNC(int, wxSnprintf, wxDoSnprintf)
869 int wxDoSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
870 int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
871 #else
872 #define wxSnprintf wxSnprintf_
873 #define wxVsnprintf wxVsnprintf_
874 #endif
875
876 /*
877 various functions which might not be available in libc and for which we
878 provide our own replacements in wxchar.cpp
879 */
880
881 /* ctype.h functions */
882
883 /* RN: Used only under OSX <= 10.2 currently */
884 #ifdef wxNEED_WX_CTYPE_H
885 WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch);
886 WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch);
887 WXDLLIMPEXP_BASE int wxIscntrl(wxChar ch);
888 WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
889 WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
890 WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
891 WXDLLIMPEXP_BASE int wxIsprint(wxChar ch);
892 WXDLLIMPEXP_BASE int wxIspunct(wxChar ch);
893 WXDLLIMPEXP_BASE int wxIsspace(wxChar ch);
894 WXDLLIMPEXP_BASE int wxIsupper(wxChar ch);
895 WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
896 WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
897 WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
898 #endif /* wxNEED_WX_CTYPE_H */
899
900 /* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
901 /* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
902 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
903 #undef wxIsspace
904 #define wxIsspace(c) ((((unsigned)(wxChar)c) < 128) && isspace(c))
905 #endif /* VC++ */
906
907 /*
908 a few compilers don't have the (non standard but common) isascii function,
909 define it ourselves for them
910 */
911 #ifndef isascii
912 #if defined(__MWERKS__)
913 #define wxNEED_ISASCII
914 #elif defined(_WIN32_WCE)
915 #if _WIN32_WCE <= 211
916 #define wxNEED_ISASCII
917 #endif
918 #endif
919 #endif /* isascii */
920
921 #ifdef wxNEED_ISASCII
922 inline int isascii(int c) { return (unsigned)c < 0x80; }
923 #endif
924
925 #ifdef _WIN32_WCE
926 #if _WIN32_WCE <= 211
927 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
928 #endif
929 #endif /* _WIN32_WCE */
930
931 /*
932 we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
933 initial versions of this header -- now it is too late to remove it so
934 although we fixed the function/macro name above, still provide the
935 backwards-compatible synonym.
936 */
937 #define wxIsctrl wxIscntrl
938
939 /* string.h functions */
940 #ifndef strdup
941 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
942 #define wxNEED_STRDUP
943 #elif defined(__WXWINCE__)
944 #if _WIN32_WCE <= 211
945 #define wxNEED_STRDUP
946 #endif
947 #endif
948 #endif /* strdup */
949
950 #ifdef wxNEED_STRDUP
951 WXDLLIMPEXP_BASE char *strdup(const char* s);
952 #endif
953
954 /* RN: Used only under OSX <= 10.2 currently
955 The __cplusplus ifdefs are messy, but they are required to build
956 the regex library, since c does not support function overloading
957 */
958 #ifdef wxNEED_WX_STRING_H
959 # ifdef __cplusplus
960 extern "C" {
961 # endif
962 WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
963 WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
964 WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2);
965 WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2);
966 WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
967 WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject);
968 WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
969 WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
970 WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
971 WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
972 WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c);
973 WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept);
974 WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
975 # ifdef __cplusplus
976 }
977 # endif
978
979 /* These functions use C++, so we can't c extern them */
980 WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr);
981 WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
982 WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
983 WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
984
985 /* inlined versions */
986 #ifdef __cplusplus
987 inline wxChar * wxStrchr(wxChar *s, wxChar c)
988 { return (wxChar *)wxStrchr((const wxChar *)s, c); }
989 inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
990 { return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
991 inline wxChar * wxStrrchr(wxChar *s, wxChar c)
992 { return (wxChar *)wxStrrchr((const wxChar *)s, c); }
993 inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
994 { return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
995 #endif
996
997 #endif /* wxNEED_WX_STRING_H */
998
999 #ifndef wxStrdupA
1000 WXDLLIMPEXP_BASE char *wxStrdupA(const char *psz);
1001 #endif
1002
1003 #ifndef wxStrdupW
1004 WXDLLIMPEXP_BASE wchar_t *wxStrdupW(const wchar_t *pwz);
1005 #endif
1006
1007 #ifndef wxStricmp
1008 WXDLLIMPEXP_BASE int wxStricmp(const wxChar *psz1, const wxChar *psz2);
1009 #endif
1010
1011 #ifndef wxStrnicmp
1012 WXDLLIMPEXP_BASE int wxStrnicmp(const wxChar *psz1, const wxChar *psz2, size_t len);
1013 #endif
1014
1015 #ifndef wxStrtok
1016 WXDLLIMPEXP_BASE wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
1017 #endif
1018
1019 #ifdef __cplusplus
1020 #ifndef wxSetlocale
1021 class WXDLLIMPEXP_BASE wxWCharBuffer;
1022 WXDLLIMPEXP_BASE wxWCharBuffer wxSetlocale(int category, const wxChar *locale);
1023 #endif
1024 #endif
1025
1026 /* stdio.h functions */
1027 #ifdef wxNEED_WX_STDIO_H
1028 #include <stdio.h>
1029 WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode);
1030 WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
1031 WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
1032 WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
1033
1034 /* *printf() family is handled separately */
1035 #endif /* wxNEED_WX_STDIO_H */
1036
1037
1038 /* stdlib.h functions */
1039 #ifndef wxAtof
1040 WXDLLIMPEXP_BASE double wxAtof(const wxChar *psz);
1041 #endif
1042
1043 #ifdef wxNEED_WX_STDLIB_H
1044 WXDLLIMPEXP_BASE int wxAtoi(const wxChar *psz);
1045 WXDLLIMPEXP_BASE long wxAtol(const wxChar *psz);
1046 WXDLLIMPEXP_BASE wxChar * wxGetenv(const wxChar *name);
1047 WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz);
1048 #endif
1049
1050
1051 /* time.h functions */
1052 #ifdef wxNEED_WX_TIME_H
1053 #if defined(__MWERKS__) && defined(macintosh)
1054 #include <time.h>
1055 #endif
1056 /*silent gabby compilers*/
1057 struct tm;
1058 WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
1059 const wxChar *fmt,
1060 const struct tm *tm);
1061 #endif /* wxNEED_WX_TIME_H */
1062
1063 #ifndef wxCtime
1064 #include <time.h>
1065 WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep);
1066 #endif
1067
1068
1069 /* missing functions in some WinCE versions */
1070 #ifdef _WIN32_WCE
1071 #if (_WIN32_WCE < 300)
1072 WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
1073 #endif
1074 #endif /* _WIN32_WCE */
1075
1076 /* multibyte to wide char conversion functions and macros */
1077
1078 #if wxUSE_WCHAR_T
1079 /* multibyte<->widechar conversion */
1080 WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
1081 WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
1082
1083 #if wxUSE_UNICODE
1084 #define wxMB2WX wxMB2WC
1085 #define wxWX2MB wxWC2MB
1086 #define wxWC2WX wxStrncpy
1087 #define wxWX2WC wxStrncpy
1088 #else
1089 #define wxMB2WX wxStrncpy
1090 #define wxWX2MB wxStrncpy
1091 #define wxWC2WX wxWC2MB
1092 #define wxWX2WC wxMB2WC
1093 #endif
1094 #else /* !wxUSE_UNICODE */
1095 /* Why is this here?
1096 #error ha */
1097 /* No wxUSE_WCHAR_T: we have to do something (JACS) */
1098 #define wxMB2WC wxStrncpy
1099 #define wxWC2MB wxStrncpy
1100 #define wxMB2WX wxStrncpy
1101 #define wxWX2MB wxStrncpy
1102 #define wxWC2WX wxWC2MB
1103 #define wxWX2WC wxMB2WC
1104 #endif
1105
1106 /*
1107 RN: The following are not normal versions of memcpy et al., rather
1108 these are either char or widechar versions depending on
1109 if unicode is used or not.
1110 */
1111
1112 #ifdef __cplusplus
1113
1114 //
1115 // RN: We could do the usual tricky compiler detection here,
1116 // and use their variant (such as wmemchr, etc.). The problem
1117 // is that these functions are quite rare, even though they are
1118 // part of the current POSIX standard. In addition, most compilers
1119 // (including even MSC) inline them just like we do right in their
1120 // headers.
1121 //
1122 #if wxUSE_UNICODE
1123 #include <string.h> //for mem funcs
1124
1125 //implement our own wmem variants
1126 inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l)
1127 {
1128 for(;l && *s != c;--l, ++s) {}
1129
1130 if(l)
1131 return (wxChar*)s;
1132 return NULL;
1133 }
1134
1135 inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
1136 {
1137 for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
1138
1139 if(len)
1140 return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
1141 else
1142 return 0;
1143 }
1144
1145 inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
1146 {
1147 return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
1148 }
1149
1150 inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len)
1151 {
1152 return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
1153 }
1154
1155 inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len)
1156 {
1157 wxChar* szRet = szOut;
1158
1159 while (len--)
1160 *szOut++ = cIn;
1161
1162 return szRet;
1163 }
1164
1165 #else /* !wxUSE_UNICODE */
1166 # define wxTmemchr memchr
1167 # define wxTmemcmp memcmp
1168 # define wxTmemcpy memcpy
1169 # define wxTmemmove memmove
1170 # define wxTmemset memset
1171 #endif /* wxUSE_UNICODE/!wxUSE_UNICODE */
1172
1173 #endif /*__cplusplus*/
1174
1175 #endif /* _WX_WXCRT_H_ */