Browse Source

Fixed false positive bug in String::EndsWith().

Lasse Öörni 12 years ago
parent
commit
ebdf337610
2 changed files with 3 additions and 2 deletions
  1. 2 1
      Source/Engine/Container/Str.cpp
  2. 1 1
      Source/Engine/Container/Str.h

+ 2 - 1
Source/Engine/Container/Str.cpp

@@ -688,7 +688,8 @@ bool String::StartsWith(const String& str, bool caseSensitive) const
 
 bool String::EndsWith(const String& str, bool caseSensitive) const
 {
-    return FindLast(str, Length() - 1, caseSensitive) == Length() - str.Length();
+    unsigned pos = FindLast(str, Length() - 1, caseSensitive);
+    return pos != NPOS && pos == Length() - str.Length();
 }
 
 int String::Compare(const String& str, bool caseSensitive) const

+ 1 - 1
Source/Engine/Container/Str.h

@@ -359,7 +359,7 @@ public:
     /// Return whether starts with a string.
     bool StartsWith(const String& str, bool caseSensitive = true) const;
     /// Return whether ends with a string.
-    bool EndsWith(const String& str, bool casSensitive = true) const;
+    bool EndsWith(const String& str, bool caseSensitive = true) const;
     /// Return the C string.
     const char* CString() const { return buffer_; }
     /// Return length.