Author: fabien
Date: 2012-04-23 20:52:00 -0700 (Mon, 23 Apr 2012)
New Revision: 9396
Log:
improved ascii strcasecmp, and use it in font sort instead of strcasecmp
Modified:
branches/branch-1.3/src/fl_set_fonts_xft.cxx
branches/branch-1.3/src/flstring.c
Modified: branches/branch-1.3/src/fl_set_fonts_xft.cxx
===================================================================
--- branches/branch-1.3/src/fl_set_fonts_xft.cxx 2012-04-24 03:34:26 UTC
(rev 9395)
+++ branches/branch-1.3/src/fl_set_fonts_xft.cxx 2012-04-24 03:52:00 UTC
(rev 9396)
@@ -65,7 +65,7 @@
// 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
Modified: branches/branch-1.3/src/flstring.c
===================================================================
--- branches/branch-1.3/src/flstring.c 2012-04-24 03:34:26 UTC (rev 9395)
+++ branches/branch-1.3/src/flstring.c 2012-04-24 03:52:00 UTC (rev 9396)
@@ -98,8 +98,10 @@
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 @@
if ( (*s-0x20)!=*t || !C_RANGE(*s,'a','z') ) return +1;
}
}
+
return 0;
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit