-
-// these two (and wxCRT_StrncmpW below) are extern "C" because they are needed
-// by regex code, the rest isn't needed, so it's not declared as extern "C"
-#ifndef wxCRT_StrlenA
-WXDLLEXPORT size_t wxCRT_StrlenA(const char *s)
- { return wxCRT_DoStrlen(s); }
-#endif
-#ifndef wxCRT_StrlenW
-extern "C" WXDLLEXPORT size_t wxCRT_StrlenW(const wchar_t *s)
- { return wxCRT_DoStrlen(s); }
-#endif
-
-#ifndef wxCRT_StrncatW
-WXDLLEXPORT wchar_t * wxCRT_StrncatW(wchar_t *dest, const wchar_t *src, size_t n)
-{
- wchar_t *ret = dest;
- while (*dest) dest++;
- while (n && (*dest++ = *src++)) n--;
- return ret;
-}
-#endif
-
-#ifndef wxCRT_StrncmpW
-extern "C"
-WXDLLEXPORT int wxCRT_StrncmpW(const wchar_t *s1, const wchar_t *s2, size_t n)
-{
- while (n && (*s1 == *s2) && *s1) n--, s1++, s2++;
- if (n) {
- if ((wxUChar)*s1 < (wxUChar)*s2) return -1;
- if ((wxUChar)*s1 > (wxUChar)*s2) return 1;
- }
- return 0;
-}
-#endif
-
-#ifndef wxCRT_StrncpyW
-WXDLLEXPORT wchar_t * wxCRT_StrncpyW(wchar_t *dest, const wchar_t *src, size_t n)
-{
- wchar_t *ret = dest;
- while (n && (*dest++ = *src++)) n--;
- while (n) *dest++=0, n--; // the docs specify padding with zeroes
- return ret;
-}
-#endif
-
-#ifndef wxCRT_StrpbrkW
-WXDLLEXPORT const wchar_t * wxCRT_StrpbrkW(const wchar_t *s, const wchar_t *accept)
-{
- while (*s && !wxCRT_Strchr(accept, *s))
- s++;
-
- return *s ? s : NULL;
-}
-#endif
-
-#ifndef wxCRT_StrrchrW
-WXDLLEXPORT const wchar_t * wxCRT_StrrchrW(const wchar_t *s, wchar_t c)
-{
- const wchar_t *ret = NULL;
- do
- {
- if ( *s == c )
- ret = s;
- s++;
- }
- while ( *s );
-
- return ret;
-}
-#endif
-
-#ifndef wxCRT_StrspnW
-WXDLLEXPORT size_t wxCRT_StrspnW(const wchar_t *s, const wchar_t *accept)
-{
- size_t len = 0;
- while (wxCRT_Strchr(accept, *s++)) len++;
- return len;
-}
-#endif
-
-#ifndef wxCRT_StrstrW
-WXDLLEXPORT const wchar_t *wxCRT_StrstrW(const wchar_t *haystack, const wchar_t *needle)
-{
- wxASSERT_MSG( needle != NULL, _T("NULL argument in wxCRT_Strstr") );
-
- // VZ: this is not exactly the most efficient string search algorithm...
-
- const size_t len = wxStrlen(needle);
-
- while ( const wchar_t *fnd = wxCRT_Strchr(haystack, *needle) )
- {
- if ( !wxCRT_Strncmp(fnd, needle, len) )
- return fnd;
-
- haystack = fnd + 1;
- }
-
- return NULL;
-}
-#endif
-
-#ifndef wxCRT_StrtodW
-WXDLLEXPORT double wxCRT_StrtodW(const wchar_t *nptr, wchar_t **endptr)
-{
- const wchar_t *start = nptr;
-
- // FIXME: only correct for C locale
- while (wxIsspace(*nptr)) nptr++;
- if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++;
- while (wxIsdigit(*nptr)) nptr++;
- if (*nptr == wxT('.')) {
- nptr++;
- while (wxIsdigit(*nptr)) nptr++;
- }
- if (*nptr == wxT('E') || *nptr == wxT('e')) {
- nptr++;
- if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++;
- while (wxIsdigit(*nptr)) nptr++;
- }
-
- wxString data(nptr, nptr-start);
- wxWX2MBbuf dat = data.mb_str(wxConvLibc);
- char *rdat = wxMBSTRINGCAST dat;
- double ret = strtod(dat, &rdat);
-
- if (endptr) *endptr = (wchar_t *)(start + (rdat - (const char *)dat));
-
- return ret;
-}
-#endif // !wxCRT_StrtodW
-
-#ifndef wxCRT_StrtolW
-WXDLLEXPORT long int wxCRT_StrtolW(const wchar_t *nptr, wchar_t **endptr, int base)
-{
- const wchar_t *start = nptr;
-
- // FIXME: only correct for C locale
- while (wxIsspace(*nptr)) nptr++;
- if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++;
- if (((base == 0) || (base == 16)) &&
- (nptr[0] == wxT('0') && nptr[1] == wxT('x'))) {
- nptr += 2;
- base = 16;
- }
- else if ((base == 0) && (nptr[0] == wxT('0'))) base = 8;
- else if (base == 0) base = 10;
-
- while ((wxIsdigit(*nptr) && (*nptr - wxT('0') < base)) ||
- (wxIsalpha(*nptr) && (wxToupper(*nptr) - wxT('A') + 10 < base))) nptr++;
-
- wxString data(start, nptr-start);
- wxWX2MBbuf dat = data.mb_str(wxConvLibc);
- char *rdat = wxMBSTRINGCAST dat;
- long int ret = strtol(dat, &rdat, base);
-
- if (endptr) *endptr = (wchar_t *)(start + (rdat - (const char *)dat));
-
- return ret;
-}
-#endif // !wxCRT_StrtolW
-
-#ifndef wxCRT_StrtoulW
-WXDLLEXPORT unsigned long int wxCRT_StrtoulW(const wchar_t *nptr, wchar_t **endptr, int base)
-{
- return (unsigned long int) wxCRT_StrtolW(nptr, endptr, base);
-}