]> git.saurik.com Git - wxWidgets.git/commitdiff
Correct mistakes in wxStripExtension - correct wxString::npos. Spurred by 1073642...
authorRyan Norton <wxprojects@comcast.net>
Wed, 1 Dec 2004 23:55:42 +0000 (23:55 +0000)
committerRyan Norton <wxprojects@comcast.net>
Wed, 1 Dec 2004 23:55:42 +0000 (23:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h
src/common/filefn.cpp
src/common/string.cpp

index bdd38c93a12d27c223a595ca73cedb5cde0c48b4..bd343a081dda87ebc295f7ed14ebed08084c5f13 100644 (file)
@@ -80,16 +80,8 @@ class WXDLLIMPEXP_BASE wxString;
 // constants
 // ----------------------------------------------------------------------------
 
-#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
-// must define this static for VA or else you get multiply defined symbols everywhere
-extern const unsigned int wxSTRING_MAXLEN;
-
-#else
 // maximum possible length for a string means "take all string" everywhere
-//  (as sizeof(StringData) is unknown here, we subtract 100)
-const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100;
-
-#endif
+#define wxSTRING_MAXLEN wxStringBase::npos
 
 // ----------------------------------------------------------------------------
 // global data
index c33c44c174052fb5e606aaf6fc581b52ad2643a1..0a2241edd8a14b058e049c13963376c930e8698a 100644 (file)
@@ -361,17 +361,16 @@ void wxStripExtension(wxChar *buffer)
 
 void wxStripExtension(wxString& buffer)
 {
-  size_t len = buffer.Length();
-  size_t i = len-1;
-  while (i > 0)
-  {
-    if (buffer.GetChar(i) == wxT('.'))
+    //RN:  Be careful about the handling the case where 
+    //buffer.Length() == 0
+    for(size_t i = buffer.Length() - 1; i != wxString::npos; --i)
     {
-      buffer = buffer.Left(i);
-      break;
+        if (buffer.GetChar(i) == wxT('.'))
+        {
+          buffer = buffer.Left(i);
+          break;
+        }
     }
-    i --;
-  }
 }
 
 // Destructive removal of /./ and /../ stuff
index 316e0421822b5b924e84a5b2f2a5cce234b6dd07..6b21ca1b09588be2a81743b63c5c93ffc86c5c07 100644 (file)
 // static class variables definition
 // ---------------------------------------------------------------------------
 
-#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
-// must define this static for VA or else you get multiply defined symbols
-// everywhere
-const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100;
-#endif // Visual Age
-
 #if !wxUSE_STL
-  const size_t wxStringBase::npos = wxSTRING_MAXLEN;
+  //According to STL _must_ be a -1 size_t
+  const size_t wxStringBase::npos = (size_t) -1;
 #endif
 
 // ----------------------------------------------------------------------------