diff options
Diffstat (limited to 'src/AutoComplete.cxx')
-rw-r--r-- | src/AutoComplete.cxx | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index c3ebd9c46..779d34965 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -197,9 +197,7 @@ int AutoComplete::GetSelection() const { } std::string AutoComplete::GetValue(int item) const { - char value[maxItemLen]; - lb->GetValue(item, value, sizeof(value)); - return std::string(value); + return lb->GetValue(item); } void AutoComplete::Show(bool show) { @@ -235,21 +233,20 @@ void AutoComplete::Select(const char *word) { int end = lb->Length() - 1; // upper bound of the api array block to search while ((start <= end) && (location == -1)) { // Binary searching loop int pivot = (start + end) / 2; - char item[maxItemLen]; - lb->GetValue(sortMatrix[pivot], item, maxItemLen); + std::string item = GetValue(sortMatrix[pivot]); int cond; if (ignoreCase) - cond = CompareNCaseInsensitive(word, item, lenWord); + cond = CompareNCaseInsensitive(word, item.c_str(), lenWord); else - cond = strncmp(word, item, lenWord); + cond = strncmp(word, item.c_str(), lenWord); if (!cond) { // Find first match while (pivot > start) { - lb->GetValue(sortMatrix[pivot-1], item, maxItemLen); + item = lb->GetValue(sortMatrix[pivot-1]); if (ignoreCase) - cond = CompareNCaseInsensitive(word, item, lenWord); + cond = CompareNCaseInsensitive(word, item.c_str(), lenWord); else - cond = strncmp(word, item, lenWord); + cond = strncmp(word, item.c_str(), lenWord); if (0 != cond) break; --pivot; @@ -259,12 +256,12 @@ void AutoComplete::Select(const char *word) { && ignoreCaseBehaviour == SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE) { // Check for exact-case match for (; pivot <= end; pivot++) { - lb->GetValue(sortMatrix[pivot], item, maxItemLen); - if (!strncmp(word, item, lenWord)) { + item = lb->GetValue(sortMatrix[pivot]); + if (!strncmp(word, item.c_str(), lenWord)) { location = pivot; break; } - if (CompareNCaseInsensitive(word, item, lenWord)) + if (CompareNCaseInsensitive(word, item.c_str(), lenWord)) break; } } @@ -282,12 +279,11 @@ void AutoComplete::Select(const char *word) { } else { if (autoSort == SC_ORDER_CUSTOM) { // Check for a logically earlier match - char item[maxItemLen]; for (int i = location + 1; i <= end; ++i) { - lb->GetValue(sortMatrix[i], item, maxItemLen); - if (CompareNCaseInsensitive(word, item, lenWord)) + std::string item = lb->GetValue(sortMatrix[i]); + if (CompareNCaseInsensitive(word, item.c_str(), lenWord)) break; - if (sortMatrix[i] < sortMatrix[location] && !strncmp(word, item, lenWord)) + if (sortMatrix[i] < sortMatrix[location] && !strncmp(word, item.c_str(), lenWord)) location = i; } } |