#define wxStrspn _tcsspn
#define wxStrstr _tcsstr
#define wxStrtod _tcstod
-#define wxStrtok _tcstok
+// is there a _tcstok[_r] ?
#define wxStrtol _tcstol
#define wxStrtoul _tcstoul
#define wxStrxfrm _tcsxfrm
#define wxUngetc _tungetc
#define wxVfprint _vftprintf
#define wxVprintf _vtprintf
+#define wxVsscanf _vstscanf
#define wxVsprintf _vstprintf
// stdlib.h functions
+#if !wxUSE_UNICODE
+#define wxAtof atof
+#endif
#define wxAtoi _ttoi
#define wxAtol _ttol
#define wxGetenv _tgetenv
#define wxIsspace iswspace
#define wxIsupper iswupper
#define wxIsxdigit iswxdigit
-#define wxTolower towlower
-#define wxToupper towupper
+
+#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
+ // /usr/include/wctype.h incorrectly declares translations tables which
+ // provokes tons of compile-time warnings - try to correct this
+ #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
+ #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
+#else
+ #define wxTolower towlower
+ #define wxToupper towupper
+#endif // gcc/!gcc
// string.h functions (wchar.h)
#define wxStrcat wcscat
#define wxStrxfrm wcsxfrm
// glibc doesn't have wc equivalents of the other stuff
-// do we need to write wrappers for them?
+#define wxNEED_WX_STDIO_H
+#define wxNEED_WX_STDLIB_H
+#define wxNEED_WX_TIME_H
#else
#error "Please define your compiler's Unicode conventions in wxChar.h"
#endif
#else//!Unicode
+#include <ctype.h>
+#include <string.h>
+
#if 0 // temporary - preserve binary compatibilty
typedef char wxChar;
typedef signed char wxSChar;
#define wxStrcoll strcoll
#define wxStrcpy strcpy
#define wxStrcspn strcspn
+#define wxStrdup strdup
#define wxStrncat strncat
#define wxStrncmp strncmp
#define wxStrncpy strncpy
#define wxStrspn strspn
#define wxStrstr strstr
#define wxStrtod strtod
-#define wxStrtok strtok
+// #define wxStrtok strtok_r // this needs a configure check
#define wxStrtol strtol
#define wxStrtoul strtoul
#define wxStrxfrm strxfrm
#define wxUngetc ungetc
#define wxVfprint vfprintf
#define wxVprintf vprintf
+#define wxVsscanf vsscanf
#define wxVsprintf vsprintf
// stdlib.h functions
+#define wxAtof atof
#define wxAtoi atoi
#define wxAtol atol
#define wxGetenv getenv
#error "Please define string case-insensitive compare for your OS/compiler"
#endif // OS/compiler
-/// portable strdup
-inline wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz)
-#if !wxUSE_UNICODE
- { return strdup(psz); }
+// multibyte<->widechar conversion
+size_t WXDLLEXPORT wxMB2WC(wchar_t *buf, const char *psz, size_t n);
+size_t WXDLLEXPORT wxWC2MB(char *buf, const wchar_t *psz, size_t n);
+#if wxUSE_UNICODE
+#define wxMB2WX wxMB2WC
+#define wxWX2MB wxWC2MB
+#define wxWC2WX wxStrncpy
+#define wxWX2WC wxStrncpy
#else
- {
- size_t size = (wxStrlen(psz) + 1) * sizeof(wxChar);
- wxChar *ret = (wxChar *) malloc(size);
- memcpy(ret, psz, size);
- return ret;
- }
+#define wxMB2WX wxStrncpy
+#define wxWX2MB wxStrncpy
+#define wxWC2WX wxWC2MB
+#define wxWX2WC wxMB2WC
+#endif
+
+// if libc versions are not available, use replacements defined in wxchar.cpp
+#ifndef wxStrdup
+wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz);
+#endif
+
+#ifndef wxStrtok
+wxChar * WXDLLEXPORT wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
+#endif
+
+#ifndef wxSetlocale
+wxChar * WXDLLEXPORT wxSetlocale(int category, const wxChar *locale);
+#endif
+
+#ifdef wxNEED_WX_STDIO_H
+#include <stdio.h>
+#include <stdarg.h>
+int WXDLLEXPORT wxPrintf(const wxChar *fmt, ...);
+int WXDLLEXPORT wxVprintf(const wxChar *fmt, va_list argptr);
+int WXDLLEXPORT wxFprintf(FILE *stream, const wxChar *fmt, ...);
+int WXDLLEXPORT wxVfprintf(FILE *stream, const wxChar *fmt, va_list argptr);
+int WXDLLEXPORT wxSprintf(wxChar *buf, const wxChar *fmt, ...);
+int WXDLLEXPORT wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr);
+int WXDLLEXPORT wxSscanf(const wxChar *buf, const wxChar *fmt, ...);
+int WXDLLEXPORT wxVsscanf(const wxChar *buf, const wxChar *fmt, va_list argptr);
+#endif
+
+#ifndef wxAtof
+double WXDLLEXPORT wxAtof(const wxChar *psz);
+#endif
+
+#ifdef wxNEED_WX_STDLIB_H
+int WXDLLEXPORT wxAtoi(const wxChar *psz);
+long WXDLLEXPORT wxAtol(const wxChar *psz);
+wxChar * WXDLLEXPORT wxGetenv(const wxChar *name);
+int WXDLLEXPORT wxSystem(const wxChar *psz);
#endif
#endif