]> git.saurik.com Git - wxWidgets.git/commitdiff
use our own mbstowcs() and wcstombs() implementations with Metrowerks as MSL CRT...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 6 Jan 2006 16:52:54 +0000 (16:52 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 6 Jan 2006 16:52:54 +0000 (16:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36735 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/wxchar.h
src/common/wxchar.cpp

index 6d560af9561d133d719262a93d3ca89146ee1341..5320075a0f9d1baec1a7c930575eecbad1e39459 100644 (file)
     #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);
index 65024d40d804a52e1c937af1cd120a0ebdb853bb..b3f6003eeac0935d2ceb817bcf47b7a07f17a029 100644 (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)