diff options
author | nyamatongwe <unknown> | 2005-04-18 01:16:53 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2005-04-18 01:16:53 +0000 |
commit | f1b2a14f13917702c0d16debb11a20bd3d3ec961 (patch) | |
tree | 8e96e309824cb10e1226f83bb9f66f790aa10b0a /src/PropSet.cxx | |
parent | 6779791c7b7df7e581a38fd3027b41d80bb5697b (diff) | |
download | scintilla-mirror-f1b2a14f13917702c0d16debb11a20bd3d3ec961.tar.gz |
Large SQL patch from Carsten Sperber supports scripts written in SQL*Plus.
Diffstat (limited to 'src/PropSet.cxx')
-rw-r--r-- | src/PropSet.cxx | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/PropSet.cxx b/src/PropSet.cxx index 34825c7fc..287934980 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -883,6 +883,68 @@ bool WordList::InList(const char *s) { return false; } +/** similar to InList, but word s can be a substring of keyword. + * eg. the keyword define is defined as def~ine. This means the word must start + * with def to be a keyword, but also defi, defin and define are valid. + * The marker is ~ in this case. + */ +bool WordList::InListAbbreviated(const char *s, const char marker) { + if (0 == words) + return false; + if (!sorted) { + sorted = true; + SortWordList(words, len); + for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) + starts[k] = -1; + for (int l = len - 1; l >= 0; l--) { + unsigned char indexChar = words[l][0]; + starts[indexChar] = l; + } + } + unsigned char firstChar = s[0]; + int j = starts[firstChar]; + if (j >= 0) { + while (words[j][0] == firstChar) { + bool isSubword = false; + int start = 1; + if (words[j][1] == marker) { + isSubword = true; + start++; + } + if (s[1] == words[j][start]) { + const char *a = words[j] + start; + const char *b = s + 1; + while (*a && *a == *b) { + a++; + if (*a == marker) { + isSubword = true; + a++; + } + b++; + } + if ((!*a || isSubword) && !*b) + return true; + } + j++; + } + } + j = starts['^']; + if (j >= 0) { + while (words[j][0] == '^') { + const char *a = words[j] + 1; + const char *b = s; + while (*a && *a == *b) { + a++; + b++; + } + if (!*a) + return true; + j++; + } + } + return false; +} + /** * Returns an element (complete) of the wordlist array which has * the same beginning as the passed string. |