diff options
author | nyamatongwe <devnull@localhost> | 2000-08-27 09:20:56 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-08-27 09:20:56 +0000 |
commit | 02cc55d64d4b12761629e9062048e8cbd7bbec01 (patch) | |
tree | 98ab20343d44e776c1f1d8c5cfb5468e48f86976 /src/PropSet.cxx | |
parent | f67319305972bdb081cf43a8c08c12877e2ed262 (diff) | |
download | scintilla-mirror-02cc55d64d4b12761629e9062048e8cbd7bbec01.tar.gz |
Fixed sorting to use qsort by implementing a string comparison
function rather than passing strcmp in directly.
Diffstat (limited to 'src/PropSet.cxx')
-rw-r--r-- | src/PropSet.cxx | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/PropSet.cxx b/src/PropSet.cxx index 60e6922a6..df669a88b 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -393,41 +393,15 @@ void WordList::SetFromAllocated() { words = ArrayFromWordList(list, &len, onlyLineEnds); } -#ifdef __MINGW32__ -// Shell sort based upon public domain C implementation by Raymond Gardner 1991 -// Used here because of problems with mingw qsort. -static void SortWordList(char **words, unsigned int len) { - unsigned int gap = len / 2; - - while (gap > 0) { - unsigned int i = gap; - while (i < len) { - unsigned int j = i; - char **a = words + j; - do { - j -= gap; - char **b = a; - a -= gap; - if (strcmp(*a, *b) > 0) { - char *tmp = *a; - *a = *b; - *b = tmp; - } else { - break; - } - } while (j >= gap); - i++; - } - gap = gap / 2; - } +int cmpString(const void *a1, const void *a2) { + // Can't work out the correct incantation to use modern casts here + return strcmp(*(char**)(a1), *(char**)(a2)); } -#else -// traditional qsort - hope it works elsewhere... + static void SortWordList(char **words, unsigned int len) { - qsort (reinterpret_cast<void*>(words), len, sizeof(*words), - reinterpret_cast<int (*)(const void*, const void*)>(strcmp)); + qsort(reinterpret_cast<void*>(words), len, sizeof(*words), + cmpString); } -#endif bool WordList::InList(const char *s) { if (0 == words) |