diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AutoComplete.cxx | 30 | ||||
-rw-r--r-- | src/Platform.h | 2 |
2 files changed, 14 insertions, 18 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; } } diff --git a/src/Platform.h b/src/Platform.h index ffe52446c..d46f050d6 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -329,7 +329,7 @@ public: virtual void Select(int n)=0; virtual int GetSelection()=0; virtual int Find(const char *prefix)=0; - virtual void GetValue(int n, char *value, int len)=0; + virtual std::string GetValue(int n)=0; virtual void RegisterImage(int type, const char *xpm_data)=0; virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) = 0; virtual void ClearRegisteredImages()=0; |