diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-23 01:05:12 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-23 01:05:12 +0200 |
commit | 49a4613d94d8e500e5bd3c259693fb5ccec4612e (patch) | |
tree | ea2db28bde16c472f02b6a83651df8cf2fe486a9 /source/StringUtils.cpp | |
parent | Added a documentation for block and item handlers (diff) | |
download | cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.tar cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.tar.gz cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.tar.bz2 cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.tar.lz cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.tar.xz cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.tar.zst cuberite-49a4613d94d8e500e5bd3c259693fb5ccec4612e.zip |
Diffstat (limited to 'source/StringUtils.cpp')
-rw-r--r-- | source/StringUtils.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp index ccdbe687a..e3eb95a6e 100644 --- a/source/StringUtils.cpp +++ b/source/StringUtils.cpp @@ -172,6 +172,33 @@ int NoCaseCompare(const AString & s1, const AString & s2) +unsigned int RateCompareString(const AString & s1, const AString & s2 ) +{ + unsigned int MatchedLetters = 0; + unsigned int s1Length = s1.length(); + + if( s1Length > s2.length() ) return 0; // Definitely not a match + + for (unsigned int i = 0; i < s1Length; i++) + { + char c1 = (char)toupper( s1[i] ); + char c2 = (char)toupper( s2[i] ); + if( c1 == c2 ) + { + ++MatchedLetters; + } + else + { + break; + } + } + return MatchedLetters; +} + + + + + void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith) { size_t pos1 = iHayStack.find(iNeedle); |