X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34f9227c5a7ffde70ef48da7268821082a866134..ab2b3dd4a28041694104aa782fb0b4f91d410136:/include/wx/wxchar.h diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index c5b0529e99..fda15454f2 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -25,9 +25,15 @@ #if defined(__VISUALC__) && defined(__WIN32__) #include +#if wxUSE_UNICODE // temporary - preserve binary compatibility typedef _TCHAR wxChar; typedef _TSCHAR wxSChar; typedef _TUCHAR wxUChar; +#else +#define wxChar char +#define wxSChar signed char +#define wxUChar unsigned char +#endif // ctype.h functions #define wxIsalnum _istalnum @@ -173,9 +179,15 @@ typedef unsigned __WCHAR_TYPE__ wxUChar; #endif #else//!Unicode +#if 0 // temporary - preserve binary compatibilty typedef char wxChar; typedef signed char wxSChar; typedef unsigned char wxUChar; +#else +#define wxChar char +#define wxSChar signed char +#define wxUChar unsigned char +#endif #define _T(x) x @@ -265,7 +277,7 @@ typedef unsigned char wxUChar; inline bool WXDLLEXPORT wxIsEmpty(const wxChar *p) { return !p || !*p; } /// safe version of strlen() (returns 0 if passed NULL pointer) -inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) +inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) #if defined(__VISUALC__) { return psz ? _tcslen(psz) : 0; } #elif wxUSE_UNICODE @@ -311,5 +323,18 @@ inline int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2) #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); } +#else + { + size_t size = (wxStrlen(psz) + 1) * sizeof(wxChar); + wxChar *ret = (wxChar *) malloc(size); + memcpy(ret, psz, size); + return ret; + } +#endif + #endif //_WX_WXCHAR_H_