do not use functions from <ctypes.h>, they are locale-dependent (and slower)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
diff --git a/ChangeLog b/ChangeLog
index 2376263..81b99b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-15 David Turner <david@freetype.org>
+
+ * include/freetype/config/ftstdlib.h,
+ include/freetype/internal/ftobjs.h: as suggested by Graham Asher,
+ ensure that ft_isalnum, ft_isdigit, etc... use hard-coded values
+ instead on relying on the locale-dependent functions provided by
+ <ctypes.h>
+
2007-05-15 Graham Asher <graham.asher@btinternet.com>
* src/autofit/afcjk.c (af_cjk_hints_compute_edges): Remove unused
diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h
index 82702d3..f923f3e 100644
--- a/include/freetype/config/ftstdlib.h
+++ b/include/freetype/config/ftstdlib.h
@@ -78,15 +78,6 @@
/**********************************************************************/
-#include <ctype.h>
-
-#define ft_isalnum isalnum
-#define ft_isdigit isdigit
-#define ft_islower islower
-#define ft_isupper isupper
-#define ft_isxdigit isxdigit
-
-
#include <string.h>
#define ft_memchr memchr
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 2f49758..5f9f9e8 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -89,6 +89,26 @@ FT_BEGIN_HEADER
ft_highpow2( FT_UInt32 value );
+ /*
+ * character classification functions. Since these are used to parse font
+ * files, we must not use those in <ctypes.h> which are locale-dependent !!
+ */
+#define ft_isdigit(x) (((unsigned)(x) - '0') < 10U)
+
+#define ft_isxdigit(x) ( ((unsigned)(x) - '0') < 10U || \
+ ((unsigned)(x) - 'a') < 6U || \
+ ((unsigned)(x) - 'A') < 6U )
+
+#define ft_isupper(x) ( ((unsigned)(x) - 'A') < 26U )
+
+#define ft_islower(x) ( ((unsigned)(x) - 'a') < 26U )
+
+#define ft_isalpha(x) ( ft_is_upper(x) || ft_is_lower(x) )
+
+#define ft_isalnum(x) ( ft_isdigit(x) || ft_isalpha(x) )
+
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/