summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-02-06 16:30:56 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-02-06 16:30:56 +0100
commit55cb8081c782f8946c8af32e1ed2164b48a62506 (patch)
tree056459076a2260dcfb0e0dbff69be9ec8d360d9f /src
parentd4251d8b7351fdfde2d5873d905d698558d7392c (diff)
Don't assume strcasecmp() is a function because of Visual studio C
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Browser_.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Fl_Browser_.cxx b/src/Fl_Browser_.cxx
index 9e7343e2c..a9556f5e6 100644
--- a/src/Fl_Browser_.cxx
+++ b/src/Fl_Browser_.cxx
@@ -994,8 +994,7 @@ void Fl_Browser_::sort(int flags) {
// Simple bubble sort - pure lazyness on my side.
//
int i, j, n = -1, desc = ((flags&FL_SORT_DESCENDING)==FL_SORT_DESCENDING);
- typedef int (*sort_f_type)(const char *, const char *);
- sort_f_type sort_f = ( (flags&FL_SORT_CASEINSENSITIVE) ? strcasecmp : strcmp );
+ bool caseinsensitive = (flags&FL_SORT_CASEINSENSITIVE);
void *a =item_first(), *b, *c;
if (!a) return;
while (a) {
@@ -1011,12 +1010,14 @@ void Fl_Browser_::sort(int flags) {
const char *tb = item_text(b);
c = item_next(b);
if (desc) {
- if (sort_f(ta, tb) < 0) {
+ if ( (caseinsensitive && strcasecmp(ta, tb) < 0) ||
+ (!caseinsensitive && strcmp(ta, tb) < 0) ) {
item_swap(a, b);
swapped = 1;
}
} else {
- if (sort_f(ta, tb)>0) {
+ if ( (caseinsensitive && strcasecmp(ta, tb) > 0) ||
+ (!caseinsensitive && strcmp(ta, tb) > 0) ) {
item_swap(a, b);
swapped = 1;
}