diff options
-rw-r--r-- | include/PropSet.h | 2 | ||||
-rw-r--r-- | src/PropSet.cxx | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/include/PropSet.h b/include/PropSet.h index 62cd5da3a..597c27059 100644 --- a/include/PropSet.h +++ b/include/PropSet.h @@ -83,7 +83,7 @@ public: const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1); char *GetNearestWords(const char *wordStart, int searchLen=-1, - bool ignoreCase=false, char otherSeparator='\0'); + bool ignoreCase=false, char otherSeparator='\0', bool exactLen=false); }; inline bool IsAlphabetic(unsigned int ch) { diff --git a/src/PropSet.cxx b/src/PropSet.cxx index 41b2d5eff..a1ed39da6 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -838,8 +838,8 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1 // Found another word first = pivot; end = pivot - 1; - } - else if (cond > 0) + } + else if (cond > 0) start = pivot + 1; else if (cond <= 0) break; @@ -875,8 +875,8 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1 // Found another word first = pivot; end = pivot - 1; - } - else if (cond > 0) + } + else if (cond > 0) start = pivot + 1; else if (cond <= 0) break; @@ -937,8 +937,9 @@ char *WordList::GetNearestWords( const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, - char otherSeparator /*= '\0'*/) { - int wordlen; // length of the word part (before the '(' brace) of the api array element + char otherSeparator /*= '\0'*/, + bool exactLen /*=false*/) { + unsigned int wordlen; // length of the word part (before the '(' brace) of the api array element SString wordsNear; wordsNear.setsizegrowth(1000); int start = 0; // lower bound of the api array block to search @@ -968,6 +969,8 @@ char *WordList::GetNearestWords( (0 == CompareNCaseInsensitive(wordStart, wordsNoCase[pivot], searchLen))) { wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1; + if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1) + break; wordsNear.append(wordsNoCase[pivot], wordlen, ' '); ++pivot; } @@ -994,6 +997,8 @@ char *WordList::GetNearestWords( (0 == strncmp(wordStart, words[pivot], searchLen))) { wordlen = LengthWord(words[pivot], otherSeparator) + 1; + if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1) + break; wordsNear.append(words[pivot], wordlen, ' '); ++pivot; } |