hirokawa Fri Dec 23 13:50:29 2005 EDT
Modified files:
/php-src/ext/mbstring config.m4 php_unicode.c
Log:
fixed #29955 mb_strtoupper() / lower() broken with Turkish encoding..
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/config.m4?r1=1.59&r2=1.60&diff_format=u
Index: php-src/ext/mbstring/config.m4
diff -u php-src/ext/mbstring/config.m4:1.59 php-src/ext/mbstring/config.m4:1.60
--- php-src/ext/mbstring/config.m4:1.59 Wed Oct 26 13:49:19 2005
+++ php-src/ext/mbstring/config.m4 Fri Dec 23 13:50:29 2005
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.59 2005/10/26 13:49:19 tony2001 Exp $
+dnl $Id: config.m4,v 1.60 2005/12/23 13:50:29 hirokawa Exp $
dnl
AC_DEFUN([PHP_MBSTRING_ADD_SOURCES], [
@@ -225,6 +225,7 @@
libmbfl/nls/nls_uni.c
libmbfl/nls/nls_zh.c
libmbfl/nls/nls_hy.c
+ libmbfl/nls/nls_tr.c
])
PHP_MBSTRING_ADD_CFLAG([-DHAVE_CONFIG_H])
else
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/php_unicode.c?r1=1.11&r2=1.12&diff_format=u
Index: php-src/ext/mbstring/php_unicode.c
diff -u php-src/ext/mbstring/php_unicode.c:1.11
php-src/ext/mbstring/php_unicode.c:1.12
--- php-src/ext/mbstring/php_unicode.c:1.11 Wed Aug 3 14:07:24 2005
+++ php-src/ext/mbstring/php_unicode.c Fri Dec 23 13:50:29 2005
@@ -44,6 +44,8 @@
#include "php_unicode.h"
#include "unicode_data.h"
+ZEND_EXTERN_MODULE_GLOBALS(mbstring)
+
/*
* A simple array of 32-bit masks for lookup.
*/
@@ -96,6 +98,7 @@
}
+
MBSTRING_API int php_unicode_is_prop(unsigned long code, unsigned long mask1,
unsigned long mask2)
{
@@ -142,7 +145,23 @@
return code;
}
-MBSTRING_API unsigned long php_unicode_toupper(unsigned long code)
+MBSTRING_API unsigned long php_turkish_toupper(unsigned long code, long l,
long r, int field)
+{
+ if (code == 0x0069L) {
+ return 0x0130L;
+ }
+ return case_lookup(code, l, r, field);
+}
+
+MBSTRING_API unsigned long php_turkish_tolower(unsigned long code, long l,
long r, int field)
+{
+ if (code == 0x0049L) {
+ return 0x0131L;
+ }
+ return case_lookup(code, l, r, field);
+}
+
+MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum
mbfl_no_encoding enc TSRMLS_DC)
{
int field;
long l, r;
@@ -157,6 +176,12 @@
field = 2;
l = _uccase_len[0];
r = (l + _uccase_len[1]) - 3;
+
+ if (MBSTRG(current_language) == mbfl_no_language_turkish &&
+ enc == mbfl_no_encoding_8859_9) {
+ return php_turkish_toupper(code, l, r, field);
+ }
+
} else {
/*
* The character is title case.
@@ -168,7 +193,7 @@
return case_lookup(code, l, r, field);
}
-MBSTRING_API unsigned long php_unicode_tolower(unsigned long code)
+MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum
mbfl_no_encoding enc TSRMLS_DC)
{
int field;
long l, r;
@@ -183,6 +208,12 @@
field = 1;
l = 0;
r = _uccase_len[0] - 3;
+
+ if (MBSTRG(current_language) == mbfl_no_language_turkish &&
+ enc == mbfl_no_encoding_8859_9) {
+ return php_turkish_tolower(code, l, r, field);
+ }
+
} else {
/*
* The character is title case.
@@ -194,7 +225,7 @@
return case_lookup(code, l, r, field);
}
-MBSTRING_API unsigned long php_unicode_totitle(unsigned long code)
+MBSTRING_API unsigned long php_unicode_totitle(unsigned long code, enum
mbfl_no_encoding enc TSRMLS_DC)
{
int field;
long l, r;
@@ -246,25 +277,26 @@
size_t unicode_len;
unsigned char *unicode_ptr;
size_t i;
+ enum mbfl_no_encoding _src_encoding =
mbfl_name2no_encoding(src_encoding);
unicode = php_mb_convert_encoding(srcstr, srclen, "UCS-4BE",
src_encoding, &unicode_len TSRMLS_CC);
if (unicode == NULL)
return NULL;
- unicode_ptr = unicode;
+ unicode_ptr = (unsigned char *)unicode;
switch(case_mode) {
case PHP_UNICODE_CASE_UPPER:
for (i = 0; i < unicode_len; i+=4) {
UINT32_TO_BE_ARY(&unicode_ptr[i],
-
php_unicode_toupper(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+
php_unicode_toupper(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding
TSRMLS_CC));
}
break;
case PHP_UNICODE_CASE_LOWER:
for (i = 0; i < unicode_len; i+=4) {
UINT32_TO_BE_ARY(&unicode_ptr[i],
-
php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+
php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding
TSRMLS_CC));
}
break;
@@ -278,7 +310,7 @@
if (mode) {
if (res) {
UINT32_TO_BE_ARY(&unicode_ptr[i],
-
php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+
php_unicode_tolower(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding
TSRMLS_CC));
} else {
mode = 0;
}
@@ -286,7 +318,7 @@
if (res) {
mode = 1;
UINT32_TO_BE_ARY(&unicode_ptr[i],
-
php_unicode_totitle(BE_ARY_TO_UINT32(&unicode_ptr[i])));
+
php_unicode_totitle(BE_ARY_TO_UINT32(&unicode_ptr[i]), _src_encoding
TSRMLS_CC));
}
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php