rolland Fri Aug 26 06:21:09 2005 EDT Modified files: /php-src/ext/standard string.c Log: - Updated strrev() to handle base+combining sequences http://cvs.php.net/diff.php/php-src/ext/standard/string.c?r1=1.472&r2=1.473&ty=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.472 php-src/ext/standard/string.c:1.473 --- php-src/ext/standard/string.c:1.472 Tue Aug 23 08:53:28 2005 +++ php-src/ext/standard/string.c Fri Aug 26 06:21:07 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.472 2005/08/23 12:53:28 dmitry Exp $ */ +/* $Id: string.c,v 1.473 2005/08/26 10:21:07 rolland Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3222,7 +3222,9 @@ { zval **str; char *s, *e, *n, *p; - UChar *u_s, *u_e, *u_n, *u_p; + int32_t i, x1, x2; + UChar32 ch; + UChar *u_s, *u_n, *u_p; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &str) == FAILURE) { WRONG_PARAM_COUNT; @@ -3236,15 +3238,22 @@ u_n = eumalloc(Z_USTRLEN_PP(str)+1); u_p = u_n; u_s = Z_USTRVAL_PP(str); - u_e = u_s + Z_USTRLEN_PP(str) - 1; - while (u_e >= u_s) { - if (U16_IS_TRAIL(*u_e)) { - *u_p = *(u_e-1); - *(u_p+1) = *u_e; - u_e -= 2; u_p += 2; + i = Z_USTRLEN_PP(str); + while (i > 0) { + U16_PREV(u_s, 0, i, ch); + if (u_getCombiningClass(ch) == 0) { + u_p += zend_codepoint_to_uchar(ch, u_p); } else { - *u_p++ = *u_e--; + x2 = i; + do { + U16_PREV(u_s, 0, i, ch); + } while (u_getCombiningClass(ch) != 0); + x1 = i; + while (x1 <= x2) { + U16_NEXT(u_s, x1, Z_USTRLEN_PP(str), ch); + u_p += zend_codepoint_to_uchar(ch, u_p); + } } } *u_p = 0;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php