#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1))
+#if ZEND_USE_TOLOWER_L
+#include <locale.h>
+static _locale_t current_locale = NULL;
+/* this is true global! may lead to strange effects on ZTS, but so may setlocale() */
+#define zend_tolower(c) _tolower_l(c, current_locale)
+#else
+#define zend_tolower(c) tolower(c)
+#endif
+
ZEND_API int zend_atoi(const char *str, int str_len)
{
int retval;
return (Z_LVAL_P(op) ? 1 : 0);
}
+#ifdef ZEND_USE_TOLOWER_L
+ZEND_API void zend_update_current_locale()
+{
+ current_locale = _get_current_locale();
+}
+#endif
+
ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length)
{
register unsigned char *str = (unsigned char*)source;
register unsigned char *end = str + length;
while (str < end) {
- *result++ = tolower((int)*str++);
+ *result++ = zend_tolower((int)*str++);
}
*result = '\0';
register unsigned char *end = p + length;
while (p < end) {
- *p = tolower((int)*p);
+ *p = zend_tolower((int)*p);
p++;
}
}
len = MIN(len1, len2);
while (len--) {
- c1 = tolower((int)*(unsigned char *)s1++);
- c2 = tolower((int)*(unsigned char *)s2++);
+ c1 = zend_tolower((int)*(unsigned char *)s1++);
+ c2 = zend_tolower((int)*(unsigned char *)s2++);
if (c1 != c2) {
return c1 - c2;
}
len = MIN(length, MIN(len1, len2));
while (len--) {
- c1 = tolower((int)*(unsigned char *)s1++);
- c2 = tolower((int)*(unsigned char *)s2++);
+ c1 = zend_tolower((int)*(unsigned char *)s1++);
+ c2 = zend_tolower((int)*(unsigned char *)s2++);
if (c1 != c2) {
return c1 - c2;
}
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
#define Z_TYPE_PP(zval_pp) Z_TYPE(**zval_pp)
+#if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER) && (_MSC_VER >= 1400)
+/* This is performance improvement of tolower() on Windows and VC2005
+ * Gives 10-18% on bench.php
+ */
+#define ZEND_USE_TOLOWER_L 1
+#endif
+
+#ifdef ZEND_USE_TOLOWER_L
+ZEND_API void zend_update_current_locale();
+#else
+#define zend_update_current_locale()
+#endif
+
#endif
/*