X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2c3b684c2b17b0478f08cbbcec6ffc5802a0fb32..520e470fdd0daef09c77938db642e4583933c90d:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 56808169b1..70fdb635e1 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef wxUSE_WCSRTOMBS + #include // for wcsrtombs(), see comments where it's used +#endif // GNU + #ifdef WXSTRING_IS_WXOBJECT IMPLEMENT_DYNAMIC_CLASS(wxString, wxObject) #endif //WXSTRING_IS_WXOBJECT @@ -84,13 +88,19 @@ extern const char *g_szNul = &g_strEmpty.dummy; // iostream ones. // // ATTN: you can _not_ use both of these in the same program! -#if 0 // def _MSC_VER - #include - #define NAMESPACE std:: +#if wxUSE_IOSTREAMH +#include +#define NAMESPACE #else - #include - #define NAMESPACE -#endif //Visual C++ +#include +# ifdef _MSC_VER + using namespace std; +# endif +// for msvc (bcc50+ also) you don't need these NAMESPACE defines, +// using namespace std; takes care of that. +#define NAMESPACE std:: +#endif + NAMESPACE istream& operator>>(NAMESPACE istream& is, wxString& WXUNUSED(str)) { @@ -216,7 +226,17 @@ wxString::wxString(const void *pStart, const void *pEnd) wxString::wxString(const wchar_t *pwz) { // first get necessary size + + // NB: GNU libc5 wcstombs() is completely broken, don't use it (it doesn't + // honor the 3rd parameter, thus it will happily crash here). +#ifdef wxUSE_WCSRTOMBS + // don't know if it's really needed (or if we can pass NULL), but better safe + // than quick + mbstate_t mbstate; + size_t nLen = wcsrtombs((char *) NULL, &pwz, 0, &mbstate); +#else // !GNU libc size_t nLen = wcstombs((char *) NULL, pwz, 0); +#endif // GNU // empty? if ( nLen != 0 ) {