X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/25dd56b1d32f01cb770fbbeb50851c2814fd09a6..c693edf3bc9539378a7ac56d90d41d89c7dc7579:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index c866ca4589..1b42fd7893 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -56,6 +56,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxString, wxObject) #endif //WXSTRING_IS_WXOBJECT +#if wxUSE_UNICODE +#undef wxUSE_EXPERIMENTAL_PRINTF +#define wxUSE_EXPERIMENTAL_PRINTF 1 +#endif + // allocating extra space for each string consumes more memory but speeds up // the concatenation operations (nLen is the current string's length) // NB: EXTRA_ALLOC must be >= 0! @@ -89,6 +94,13 @@ extern const wxChar WXDLLEXPORT *g_szNul = &g_strEmpty.dummy; // conditional compilation // ---------------------------------------------------------------------------- +#if !defined(__WXSW__) && wxUSE_UNICODE + #ifdef wxUSE_EXPERIMENTAL_PRINTF + #undef wxUSE_EXPERIMENTAL_PRINTF + #endif + #define wxUSE_EXPERIMENTAL_PRINTF 1 +#endif + // we want to find out if the current platform supports vsnprintf()-like // function: for Unix this is done with configure, for Windows we test the // compiler explicitly. @@ -985,14 +997,17 @@ int wxString::Printf(const wxChar *pszFormat, ...) int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) { // static buffer to avoid dynamic memory allocation each time - static char s_szScratch[1024]; + char s_szScratch[1024]; // using static buffer causes internal compiler err +#if 0 #if wxUSE_THREADS // protect the static buffer static wxCriticalSection critsect; wxCriticalSectionLocker lock(critsect); #endif +#endif -#if 1 // the new implementation +#if wxUSE_EXPERIMENTAL_PRINTF +// the new implementation Reinit(); for (size_t n = 0; pszFormat[n]; n++) @@ -1470,7 +1485,7 @@ size_t wxString::find_last_of(const wxChar* sz, size_t nStart) const wxASSERT( nStart <= Len() ); } - for ( const char *p = c_str() + length() - 1; p >= c_str(); p-- ) + for ( const wxChar *p = c_str() + length() - 1; p >= c_str(); p-- ) { if ( wxStrchr(sz, *p) ) return p - c_str(); @@ -1490,7 +1505,7 @@ size_t wxString::find_first_not_of(const wxChar* sz, size_t nStart) const wxASSERT( nStart <= Len() ); } - size_t nAccept = strspn(c_str() + nStart, sz); + size_t nAccept = wxStrspn(c_str() + nStart, sz); if ( nAccept >= length() - nStart ) return npos; else @@ -1501,7 +1516,7 @@ size_t wxString::find_first_not_of(wxChar ch, size_t nStart) const { wxASSERT( nStart <= Len() ); - for ( const char *p = c_str() + nStart; *p; p++ ) + for ( const wxChar *p = c_str() + nStart; *p; p++ ) { if ( *p != ch ) return p - c_str(); @@ -1521,7 +1536,7 @@ size_t wxString::find_last_not_of(const wxChar* sz, size_t nStart) const wxASSERT( nStart <= Len() ); } - for ( const char *p = c_str() + nStart - 1; p >= c_str(); p-- ) + for ( const wxChar *p = c_str() + nStart - 1; p >= c_str(); p-- ) { if ( !wxStrchr(sz, *p) ) return p - c_str(); @@ -1541,7 +1556,7 @@ size_t wxString::find_last_not_of(wxChar ch, size_t nStart) const wxASSERT( nStart <= Len() ); } - for ( const char *p = c_str() + nStart - 1; p >= c_str(); p-- ) + for ( const wxChar *p = c_str() + nStart - 1; p >= c_str(); p-- ) { if ( *p != ch ) return p - c_str(); @@ -2128,7 +2143,7 @@ static void wxLoadCharacterSets(void) if (already_loaded) return; already_loaded = TRUE; -#if defined(__UNIX__) +#if defined(__UNIX__) && wxUSE_TEXTFILE // search through files in /usr/share/i18n/charmaps wxString fname; for (fname = ::wxFindFirstFile(_T("/usr/share/i18n/charmaps/*")); @@ -2181,8 +2196,7 @@ static void wxLoadCharacterSets(void) wxString uni = token.GetNextToken(); // skip whitespace again while (wxIsEmpty(uni) && token.HasMoreTokens()) uni = token.GetNextToken(); - - if ((hex.Len() > 2) && (hex.GetChar(0) == escchar) && (hex.GetChar(1) == _T('x')) && + if ((hex.Len() > 2) && (wxString(hex.GetChar(0)) == escchar) && (hex.GetChar(1) == _T('x')) && (uni.Left(2) == _T("