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
This commit is contained in:
Vadim Zeitlin
2006-01-06 16:52:54 +00:00
parent 74fd4fd42a
commit dbf9aa465e
2 changed files with 24 additions and 4 deletions

View File

@@ -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
#if !defined(__MWERKS__) && defined(__DARWIN__) && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
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
#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);

View File

@@ -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 <CoreFoundation/CoreFoundation.h>
@@ -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)