]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
added directories for Motif headers and libs under Solaris to the search path
[wxWidgets.git] / src / common / string.cpp
index 749a952b349fc86d1800d7e0ec6c0a4c95983096..9d056390460addaaaf1d1c1bd676bcabe599b3db 100644 (file)
@@ -899,8 +899,13 @@ wxString& wxString::Pad(size_t nCount, char chPad, bool bFromRight)
 // truncate the string
 wxString& wxString::Truncate(size_t uiLen)
 {
-  *(m_pchData + uiLen) = '\0';
-  GetStringData()->nDataLength = uiLen;
+  if ( uiLen < Len() ) {
+    CopyBeforeWrite();
+
+    *(m_pchData + uiLen) = '\0';
+    GetStringData()->nDataLength = uiLen;
+  }
+  //else: nothing to do, string is already short enough
 
   return *this;
 }
@@ -1070,6 +1075,19 @@ bool wxString::Matches(const char *pszMask) const
   return *pszTxt == '\0';
 }
 
+// Count the number of chars
+int wxString::Freq(char ch) const
+{
+    int count = 0;
+    int len = Len();
+    for (int i = 0; i < len; i++)
+    {
+        if (GetChar(i) == ch)
+            count ++;
+    }
+    return count;
+}
+
 // ---------------------------------------------------------------------------
 // standard C++ library string functions
 // ---------------------------------------------------------------------------
@@ -1111,6 +1129,8 @@ size_t wxString::find(const char* sz, size_t nStart, size_t n) const
 }
 #endif
 
+// Gives a duplicate symbol (presumably a case-insensitivity problem)
+#if !defined(__BORLANDC__)
 size_t wxString::find(char ch, size_t nStart) const
 {
   wxASSERT( nStart <= Len() );
@@ -1119,6 +1139,7 @@ size_t wxString::find(char ch, size_t nStart) const
 
   return p == NULL ? npos : p - c_str();
 }
+#endif
 
 size_t wxString::rfind(const wxString& str, size_t nStart) const
 {