aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2002-01-15 07:35:34 +0000
committernyamatongwe <unknown>2002-01-15 07:35:34 +0000
commitb1b5cf29e93a65ccbcb0770d2cceb0b711e433f8 (patch)
tree8c2d07245a1252a89ae24c298f0059ab99194aa9
parent0d3b13c0720abfc2eaff8de89cba4364f6a65660 (diff)
downloadscintilla-mirror-b1b5cf29e93a65ccbcb0770d2cceb0b711e433f8.tar.gz
GetNearestWord changed to use a passed in set of valid word characters
rather than a hardcoded list.
-rw-r--r--include/PropSet.h3
-rw-r--r--src/PropSet.cxx8
2 files changed, 6 insertions, 5 deletions
diff --git a/include/PropSet.h b/include/PropSet.h
index 45ee8d3bd..bef06d231 100644
--- a/include/PropSet.h
+++ b/include/PropSet.h
@@ -70,7 +70,8 @@ public:
char *Allocate(int size);
void SetFromAllocated();
bool InList(const char *s);
- const char *GetNearestWord(const char *wordStart, int searchLen = -1, bool ignoreCase = false);
+ const char *GetNearestWord(const char *wordStart, int searchLen = -1,
+ bool ignoreCase = false, SString wordCharacters="");
char *GetNearestWords(const char *wordStart, int searchLen=-1,
bool ignoreCase=false, char otherSeparator='\0');
};
diff --git a/src/PropSet.cxx b/src/PropSet.cxx
index 73ac52343..0ddbb59c2 100644
--- a/src/PropSet.cxx
+++ b/src/PropSet.cxx
@@ -567,7 +567,7 @@ bool WordList::InList(const char *s) {
* The length of the word to compare is passed too.
* Letter case can be ignored or preserved (default).
*/
-const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/) {
+const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1*/, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */) {
int start = 0; // lower bound of the api array block to search
int end = len - 1; // upper bound of the api array block to search
int pivot; // index of api array element just being compared
@@ -585,8 +585,8 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
pivot = (start + end) >> 1;
word = wordsNoCase[pivot];
cond = CompareNCaseInsensitive(wordStart, word, searchLen);
- if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
- return word; // result must not be freed with free()
+ if (!cond && (!wordCharacters.contains(word[searchLen])))
+ return word; // result must not be freed with free()
else if (cond > 0)
start = pivot + 1;
else if (cond <= 0)
@@ -597,7 +597,7 @@ const char *WordList::GetNearestWord(const char *wordStart, int searchLen /*= -1
pivot = (start + end) >> 1;
word = words[pivot];
cond = strncmp(wordStart, word, searchLen);
- if (!cond && nonFuncChar(word[searchLen])) // maybe there should be a "non-word character" test here?
+ if (!cond && (!wordCharacters.contains(word[searchLen])))
return word; // result must not be freed with free()
else if (cond > 0)
start = pivot + 1;