Author: fabien
Date: 2012-04-21 10:21:11 -0700 (Sat, 21 Apr 2012)
New Revision: 9368
Log:
STR 2771 fix: introduce a new ascii strcasecmp that does not rely on locale 
sensitive toupper tolower.

Modified:
   branches/branch-1.3/src/Fl_get_system_colors.cxx
   branches/branch-1.3/src/flstring.c
   branches/branch-1.3/src/flstring.h

Modified: branches/branch-1.3/src/Fl_get_system_colors.cxx
===================================================================
--- branches/branch-1.3/src/Fl_get_system_colors.cxx    2012-04-21 15:16:27 UTC 
(rev 9367)
+++ branches/branch-1.3/src/Fl_get_system_colors.cxx    2012-04-21 17:21:11 UTC 
(rev 9368)
@@ -312,7 +312,7 @@
 int Fl::reload_scheme() {
   Fl_Window *win;
 
-  if (scheme_ && !strcasecmp(scheme_, "plastic")) {
+  if (scheme_ && !fl_ascii_strcasecmp(scheme_, "plastic")) {
     // Update the tile image to match the background color...
     uchar r, g, b;
     int nr, ng, nb;
@@ -358,7 +358,7 @@
 
     // Use standard size scrollbars...
     Fl::scrollbar_size(16);
-  } else if (scheme_ && !strcasecmp(scheme_, "gtk+")) {
+  } else if (scheme_ && !fl_ascii_strcasecmp(scheme_, "gtk+")) {
     // Use a GTK+ inspired look-n-feel...
     if (scheme_bg_) {
       delete scheme_bg_;

Modified: branches/branch-1.3/src/flstring.c
===================================================================
--- branches/branch-1.3/src/flstring.c  2012-04-21 15:16:27 UTC (rev 9367)
+++ branches/branch-1.3/src/flstring.c  2012-04-21 17:21:11 UTC (rev 9368)
@@ -90,6 +90,21 @@
   return (srclen);
 }
 
+/**
+* locale independent ascii oriented case cmp
+* returns 0 if string successfully compare, non zero otherwise
+*/
+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++) {
+               if ( *s != *t) {
+                       if (*s<*t && (*s+0x20)!=*t ) return -1;
+                       if (*s>*t && *s!=(*t+0x20) ) return +1;
+               }
+       }
+       return 0;
+}
 
 /*
  * End of "$Id$".

Modified: branches/branch-1.3/src/flstring.h
===================================================================
--- branches/branch-1.3/src/flstring.h  2012-04-21 15:16:27 UTC (rev 9367)
+++ branches/branch-1.3/src/flstring.h  2012-04-21 17:21:11 UTC (rev 9368)
@@ -84,12 +84,15 @@
 #    define strlcpy fl_strlcpy
 #  endif /* !HAVE_STRLCPY */
 
+// locale independent ascii compare, does not introduce locale pbs as w/  case 
cmp
+FL_EXPORT extern int fl_ascii_strcasecmp(const char *s, const char *t);
+
 #  ifdef __cplusplus
 }
 #  endif /* __cplusplus */
+
 #endif /* !flstring_h */
 
-
 /*
  * End of "$Id$".
  */

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to