X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/467e04791c0d5914dc8ed8e535af607f7fc1dfe1..00dff4d222ab3525d04c819142d44159b9b52f01:/src/common/string.cpp

diff --git a/src/common/string.cpp b/src/common/string.cpp
index aa039f976b..04969d3246 100644
--- a/src/common/string.cpp
+++ b/src/common/string.cpp
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        string.cpp
+// Name:        src/common/string.cpp
 // Purpose:     wxString class
 // Author:      Vadim Zeitlin, Ryan Norton
 // Modified by:
@@ -25,14 +25,13 @@
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-  #pragma hdrstop
+    #pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
-  #include "wx/defs.h"
-  #include "wx/string.h"
-  #include "wx/intl.h"
-  #include "wx/thread.h"
+    #include "wx/string.h"
+    #include "wx/intl.h"
+    #include "wx/thread.h"
 #endif
 
 #include <ctype.h>
@@ -40,7 +39,7 @@
 #include <stdlib.h>
 
 #ifdef __SALFORDC__
-  #include <clib.h>
+    #include <clib.h>
 #endif
 
 // allocating extra space for each string consumes more memory but speeds up
@@ -1395,6 +1394,27 @@ bool wxString::StartsWith(const wxChar *prefix, wxString *rest) const
     return true;
 }
 
+
+// check that the string ends with suffix and return the rest of it in the
+// provided pointer if it is not NULL, otherwise return false
+bool wxString::EndsWith(const wxChar *suffix, wxString *rest) const
+{
+    wxASSERT_MSG( suffix, _T("invalid parameter in wxString::EndssWith") );
+
+    int start = length() - wxStrlen(suffix);
+    if ( start < 0 || wxStrcmp(c_str() + start, suffix) != 0 )
+        return false;
+
+    if ( rest )
+    {
+        // put the rest of the string into provided pointer
+        rest->assign(*this, 0, start);
+    }
+
+    return true;
+}
+
+
 // extract nCount last (rightmost) characters
 wxString wxString::Right(size_t nCount) const
 {