X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/caff62f22d16af7350d86151929dae99ebb36182..5a2e3d8c47db7f95d504ecd45f58b96c56572dd1:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 503ff915c9..9b1de655cd 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -100,6 +100,8 @@ extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = &g_strEmpty.dummy; // // ATTN: you can _not_ use both of these in the same program! +#include + wxSTD istream& operator>>(wxSTD istream& is, wxString& WXUNUSED(str)) { #if 0 @@ -168,6 +170,8 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str) #define STATISTICS_ADD(av, val) #endif // WXSTRING_STATISTICS +#if !wxUSE_STL + // =========================================================================== // wxStringData class deallocation // =========================================================================== @@ -180,8 +184,6 @@ void wxStringData::Free() } #endif -#if !wxUSE_STL - // =========================================================================== // wxStringBase // =========================================================================== @@ -968,9 +970,14 @@ wxString::wxString(const char *psz, wxMBConv& conv, size_t nLength) } else { - wxWCharBuffer buf(nLen + 1); + // the input buffer to MB2WC must always be NUL-terminated + wxCharBuffer inBuf(nLen); + memcpy(inBuf.data(), psz, nLen); + inBuf.data()[nLen] = '\0'; + + wxWCharBuffer buf(nLen); // MB2WC wants the buffer size, not the string length hence +1 - nLen = conv.MB2WC(buf.data(), psz, nLen + 1); + nLen = conv.MB2WC(buf.data(), inBuf.data(), nLen + 1); if ( nLen != (size_t)-1 ) { @@ -2325,12 +2332,12 @@ bool wxArrayString::operator==(const wxArrayString& a) const #endif // !wxUSE_STL -int wxStringSortAscending(wxString* s1, wxString* s2) +int wxCMPFUNC_CONV wxStringSortAscending(wxString* s1, wxString* s2) { return wxStrcmp(s1->c_str(), s2->c_str()); } -int wxStringSortDescending(wxString* s1, wxString* s2) +int wxCMPFUNC_CONV wxStringSortDescending(wxString* s1, wxString* s2) { return -wxStrcmp(s1->c_str(), s2->c_str()); }