From: Vadim Zeitlin Date: Fri, 6 Jan 2006 16:52:54 +0000 (+0000) Subject: use our own mbstowcs() and wcstombs() implementations with Metrowerks as MSL CRT... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/dbf9aa465e09ba6128a91d20177bfa44f0478b08 use our own mbstowcs() and wcstombs() implementations with Metrowerks as MSL CRT doesn't implement Unix98 extension of allowing to call them with NULL output parameters to just get the size of the needed buffer which we rely on git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36735 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index 6d560af956..5320075a0f 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -389,8 +389,28 @@ #define wxMbstowcs mbstowcs #define wxWcstombs wcstombs #else /* !TCHAR-aware compilers */ + /* + There are 2 unrelated problems with these functions under Mac: + a) Metrowerks MSL CRT implements them strictly in C99 sense and + doesn't support (very common) extension of allowing to call + mbstowcs(NULL, ...) which makes it pretty useless as you can't + know the size of the needed buffer + b) OS X <= 10.2 declares and even defined these functions but + doesn't really implement them -- they always return an error + + So use our own replacements in both cases. + */ + #if defined(__MWERKS__) + #define wxNEED_WX_MBSTOWCS + #endif + + #ifdef __DARWIN__ + #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 + #define wxNEED_WX_MBSTOWCS + #endif + #endif - #if !defined(__MWERKS__) && defined(__DARWIN__) && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 ) + #ifdef wxNEED_WX_MBSTOWCS /* even though they are defined and "implemented", they are bad and just stubs so we need our own - we need these even in ANSI builds!! */ WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t); diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 65024d40d8..b3f6003eea 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -1066,7 +1066,7 @@ WXDLLEXPORT int wxTolower(wxChar ch) { return (wxChar)CharLower((LPTSTR)(ch)); } WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)CharUpper((LPTSTR)(ch)); } #endif -#if defined(__DARWIN__) && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 ) +#ifdef wxNEED_WX_MBSTOWCS WXDLLEXPORT size_t wxMbstowcs (wchar_t * out, const char * in, size_t outlen) { @@ -1112,6 +1112,8 @@ WXDLLEXPORT size_t wxWcstombs (char * out, const wchar_t * in, size_t outlen) return in - origin; } +#endif // wxNEED_WX_MBSTOWCS + #if defined(wxNEED_WX_CTYPE_H) #include @@ -1143,8 +1145,6 @@ WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)toupper((char)(ch)); } #endif // wxNEED_WX_CTYPE_H -#endif // defined(__DARWIN__) and OSX <= 10.2 - #ifndef wxStrdupA WXDLLEXPORT char *wxStrdupA(const char *s)