aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2000-08-27 09:20:56 +0000
committernyamatongwe <devnull@localhost>2000-08-27 09:20:56 +0000
commit02cc55d64d4b12761629e9062048e8cbd7bbec01 (patch)
tree98ab20343d44e776c1f1d8c5cfb5468e48f86976
parentf67319305972bdb081cf43a8c08c12877e2ed262 (diff)
downloadscintilla-mirror-02cc55d64d4b12761629e9062048e8cbd7bbec01.tar.gz
Fixed sorting to use qsort by implementing a string comparison
function rather than passing strcmp in directly.
-rw-r--r--src/PropSet.cxx38
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)