-
-
-WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n)
-{
- wxChar *ret = dest;
- while (*dest) dest++;
- while (n && (*dest++ = *src++)) n--;
- return ret;
-}
-
-WXDLLEXPORT int wxStrncmp(const wxChar *s1, const wxChar *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;
-}
-
-WXDLLEXPORT wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n)
-{
- wxChar *ret = dest;
- while (n && (*dest++ = *src++)) n--;
- while (n) *dest++=0, n--; // the docs specify padding with zeroes
- return ret;
-}
-
-WXDLLEXPORT const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept)
-{
- while (*s && !wxStrchr(accept, *s))
- s++;
-
- return *s ? s : NULL;
-}
-
-WXDLLEXPORT const wxChar * wxStrrchr(const wxChar *s, wxChar c)
-{
- const wxChar *ret = NULL;
- do
- {
- if ( *s == c )
- ret = s;
- s++;
- }
- while ( *s );
-
- return ret;
-}
-
-WXDLLEXPORT size_t wxStrspn(const wxChar *s, const wxChar *accept)
-{
- size_t len = 0;
- while (wxStrchr(accept, *s++)) len++;
- return len;
-}
-
-WXDLLEXPORT const wxChar *wxStrstr(const wxChar *haystack, const wxChar *needle)
-{
- wxASSERT_MSG( needle != NULL, _T("NULL argument in wxStrstr") );
-
- // VZ: this is not exactly the most efficient string search algorithm...
-
- const size_t len = wxStrlen(needle);
-
- while ( const wxChar *fnd = wxStrchr(haystack, *needle) )
- {
- if ( !wxStrncmp(fnd, needle, len) )
- return fnd;
-
- haystack = fnd + 1;
- }
-
- return NULL;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr)
-{
- const wxChar *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 = (wxChar *)(start + (rdat - (const char *)dat));
-
- return ret;
-}
-
-WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base)
-{
- const wxChar *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 = (wxChar *)(start + (rdat - (const char *)dat));
-
- return ret;
-}
-
-WXDLLEXPORT unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base)
-{
- return (unsigned long int) wxStrtol(nptr, endptr, base);
-}
-
-#endif // wxNEED_WX_STRING_H
-
-#ifdef wxNEED_WX_STDIO_H
-WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode)
-{
- char mode_buffer[10];
- for (size_t i = 0; i < wxStrlen(mode)+1; i++)
- mode_buffer[i] = (char) mode[i];
-
- return fopen( wxConvFile.cWX2MB(path), mode_buffer );
-}
-
-WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream)
-{
- char mode_buffer[10];
- for (size_t i = 0; i < wxStrlen(mode)+1; i++)
- mode_buffer[i] = (char) mode[i];
-
- return freopen( wxConvFile.cWX2MB(path), mode_buffer, stream );
-}
-
-WXDLLEXPORT int wxRemove(const wxChar *path)
-{
- return remove( wxConvFile.cWX2MB(path) );
-}
-
-WXDLLEXPORT int wxRename(const wxChar *oldpath, const wxChar *newpath)
-{
- return rename( wxConvFile.cWX2MB(oldpath), wxConvFile.cWX2MB(newpath) );
-}