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
This commit is contained in:
parent
d90b170c8d
commit
8154316dc5
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user