From 55cb8081c782f8946c8af32e1ed2164b48a62506 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 6 Feb 2023 16:30:56 +0100 Subject: Don't assume strcasecmp() is a function because of Visual studio C --- src/Fl_Browser_.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3