summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2012-04-24 03:52:00 +0000
committerFabien Costantini <fabien@onepost.net>2012-04-24 03:52:00 +0000
commit8154316dc5af9aff37e12629a357f245bb53611e (patch)
treec4cb0c07b16ad3b4f1b66b370278248d128ba230 /src
parentd90b170c8da99402619b4fcc091aeef66a29b691 (diff)
improved ascii strcasecmp, and use it in font sort instead of strcasecmp
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9396 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-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;
}