From 566b84d2ade885cc2fb4f75d63718331db8fe2df Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 4 Feb 1999 17:39:04 +0000 Subject: [PATCH 1/1] some compilation "enhancements" git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 14 +++++++------- src/common/string.cpp | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/wx/string.h b/include/wx/string.h index fbe3c9e36d..e997410380 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -56,7 +56,7 @@ // maximum possible length for a string means "take all string" everywhere // (as sizeof(StringData) is unknown here we substract 100) -#define STRING_MAXLEN (UINT_MAX - 100) +const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100; // 'naughty' cast #define WXSTRINGCAST (char *)(const char *) @@ -206,7 +206,7 @@ private: // ctors, use Reinit() otherwise) void Init() { m_pchData = (char *)g_szNul; } // initializaes the string with (a part of) C-string - void InitWith(const char *psz, size_t nPos = 0, size_t nLen = STRING_MAXLEN); + void InitWith(const char *psz, size_t nPos = 0, size_t nLen = wxSTRING_MAXLEN); // as Init, but also frees old data void Reinit() { GetStringData()->Unlock(); Init(); } @@ -254,11 +254,11 @@ public: // string containing nRepeat copies of ch wxString(char ch, size_t nRepeat = 1); // ctor takes first nLength characters from C string - // (default value of STRING_MAXLEN means take all the string) - wxString(const char *psz, size_t nLength = STRING_MAXLEN) + // (default value of wxSTRING_MAXLEN means take all the string) + wxString(const char *psz, size_t nLength = wxSTRING_MAXLEN) { InitWith(psz, 0, nLength); } // from C string (for compilers using unsigned char) - wxString(const unsigned char* psz, size_t nLength = STRING_MAXLEN); + wxString(const unsigned char* psz, size_t nLength = wxSTRING_MAXLEN); // from wide (UNICODE) string wxString(const wchar_t *pwz); // dtor is not virtual, this class must not be inherited from! @@ -422,7 +422,7 @@ public: // simple sub-string extraction // return substring starting at nFirst of length nCount (or till the end // if nCount = default value) - wxString Mid(size_t nFirst, size_t nCount = STRING_MAXLEN) const; + wxString Mid(size_t nFirst, size_t nCount = wxSTRING_MAXLEN) const; // operator version of Mid() wxString operator()(size_t start, size_t len) const @@ -570,7 +570,7 @@ public: // return the length of the string size_t length() const { return Len(); } // return the maximum size of the string - size_t max_size() const { return STRING_MAXLEN; } + size_t max_size() const { return wxSTRING_MAXLEN; } // resize the string, filling the space with c if c != 0 void resize(size_t nSize, char ch = '\0'); // delete the contents of the string diff --git a/src/common/string.cpp b/src/common/string.cpp index 1107cc55cf..a790a44344 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -63,7 +63,7 @@ // --------------------------------------------------------------------------- #ifdef wxSTD_STRING_COMPATIBILITY - const size_t wxString::npos = STRING_MAXLEN; + const size_t wxString::npos = wxSTRING_MAXLEN; #endif // wxSTD_STRING_COMPATIBILITY // ---------------------------------------------------------------------------- @@ -104,9 +104,17 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy; // always available), but it's unsafe because it doesn't check for buffer // size - so give a warning #define wxVsprintf(buffer,len,format,argptr) vsprintf(buffer,format, argptr) -#ifndef __SC__ +#if defined(__VISUALC__) #pragma message("Using sprintf() because no snprintf()-like function defined") -#endif +#elif defined(__GNUG__) + #warning "Using sprintf() because no snprintf()-like function defined" +#elif defined(__SUNCC__) + // nothing -- I don't know about "#warning" for Sun's CC +#else + // change this to some analogue of '#warning' for your compiler + #error "Using sprintf() because no snprintf()-like function defined" +#endif //compiler + #endif // no vsnprintf // ---------------------------------------------------------------------------- @@ -211,7 +219,7 @@ void wxString::InitWith(const char *psz, size_t nPos, size_t nLength) wxASSERT( nPos <= Strlen(psz) ); - if ( nLength == STRING_MAXLEN ) + if ( nLength == wxSTRING_MAXLEN ) nLength = Strlen(psz + nPos); STATISTICS_ADD(InitialLength, nLength); @@ -611,8 +619,8 @@ wxString wxString::Mid(size_t nFirst, size_t nCount) const wxStringData *pData = GetStringData(); size_t nLen = pData->nDataLength; - // default value of nCount is STRING_MAXLEN and means "till the end" - if ( nCount == STRING_MAXLEN ) + // default value of nCount is wxSTRING_MAXLEN and means "till the end" + if ( nCount == wxSTRING_MAXLEN ) { nCount = nLen - nFirst; } -- 2.45.2