summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fl_set_fonts_xft.cxx2
-rw-r--r--src/flstring.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/fl_set_fonts_xft.cxx b/src/fl_set_fonts_xft.cxx
index fcb217673..b4cd42d6c 100644
--- a/src/fl_set_fonts_xft.cxx
+++ b/src/fl_set_fonts_xft.cxx
@@ -65,7 +65,7 @@ static int name_sort(const void *aa, const void *bb) {
// Also - the fontconfig listing returns some faces that are effectively duplicates
// as far as fltk is concerned, e.g. where there are ko or ja variants that we
// can't distinguish (since we are not yet fully UTF-*) - should we strip them here?
- return strcasecmp(*(char**)aa, *(char**)bb);
+ return fl_ascii_strcasecmp(*(char**)aa, *(char**)bb);
} // end of name_sort
} // end of extern C section
diff --git a/src/flstring.c b/src/flstring.c
index 25346b360..c407ea833 100644
--- a/src/flstring.c
+++ b/src/flstring.c
@@ -98,8 +98,10 @@ fl_strlcpy(char *dst, /* O - Destination string */
int fl_ascii_strcasecmp(const char *s, const char *t) {
if (!s || !t) return (s!=t);
- if (strlen(s) != strlen(t)) return -1;
- for(;*s; s++,t++) {
+ size_t sl=strlen(s), tl=strlen(t);
+ if (sl!=tl) return sl< tl ? -1 : +1;
+
+ for(;*s; s++,t++) {
if (*s == *t) continue;
if (*s < *t) {
if ( (*s+0x20)!=*t || !C_RANGE(*s,'A','Z') ) return -1;
@@ -107,6 +109,7 @@ int fl_ascii_strcasecmp(const char *s, const char *t) {
if ( (*s-0x20)!=*t || !C_RANGE(*s,'a','z') ) return +1;
}
}
+
return 0;
}