andrei Tue May 2 21:39:16 2006 UTC Modified files: /php-src/ext/unicode property.c unicode.c Log: Implement C/POSIX migration functions. http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/property.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/unicode/property.c diff -u php-src/ext/unicode/property.c:1.1 php-src/ext/unicode/property.c:1.2 --- php-src/ext/unicode/property.c:1.1 Tue May 2 20:58:30 2006 +++ php-src/ext/unicode/property.c Tue May 2 21:39:15 2006 @@ -14,11 +14,95 @@ +----------------------------------------------------------------------+ */ -/* $Id: property.c,v 1.1 2006/05/02 20:58:30 andrei Exp $ */ +/* $Id: property.c,v 1.2 2006/05/02 21:39:15 andrei Exp $ */ #include "php_unicode.h" +typedef UBool (*prop_check_func_t)(UChar32 ch); +static void check_property_impl(INTERNAL_FUNCTION_PARAMETERS, prop_check_func_t checker) +{ + UChar *str; + int str_len; + zend_bool result = 1; + int offset = 0; + UChar32 ch; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u", &str, &str_len) == FAILURE) { + return; + } + + while (offset < str_len && result) { + U16_NEXT(str, offset, str_len, ch); + result = checker(ch); + } + + RETURN_BOOL(result); +} + +/* + * C/POSIX migration functinos + */ + +PHP_FUNCTION(unicode_is_lower) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_islower); +} + +PHP_FUNCTION(unicode_is_upper) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isupper); +} + +PHP_FUNCTION(unicode_is_digit) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isdigit); +} + +PHP_FUNCTION(unicode_is_alpha) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isalpha); +} + +PHP_FUNCTION(unicode_is_alnum) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isalnum); +} + +PHP_FUNCTION(unicode_is_xdigit) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isxdigit); +} + +PHP_FUNCTION(unicode_is_punct) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_ispunct); +} + +PHP_FUNCTION(unicode_is_graph) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isgraph); +} + +PHP_FUNCTION(unicode_is_blank) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isblank); +} + +PHP_FUNCTION(unicode_is_space) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isspace); +} + +PHP_FUNCTION(unicode_is_cntrl) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_iscntrl); +} + +PHP_FUNCTION(unicode_is_print) +{ + check_property_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, u_isprint); +} /* http://cvs.php.net/viewcvs.cgi/php-src/ext/unicode/unicode.c?r1=1.23&r2=1.24&diff_format=u Index: php-src/ext/unicode/unicode.c diff -u php-src/ext/unicode/unicode.c:1.23 php-src/ext/unicode/unicode.c:1.24 --- php-src/ext/unicode/unicode.c:1.23 Fri Apr 21 21:10:01 2006 +++ php-src/ext/unicode/unicode.c Tue May 2 21:39:15 2006 @@ -15,10 +15,11 @@ +----------------------------------------------------------------------+ */ -/* $Id: unicode.c,v 1.23 2006/04/21 21:10:01 andrei Exp $ */ +/* $Id: unicode.c,v 1.24 2006/05/02 21:39:15 andrei Exp $ */ #include "php_unicode.h" #include "zend_unicode.h" +#include "php_property.h" void php_register_unicode_iterators(TSRMLS_D); @@ -246,6 +247,21 @@ PHP_FE(collator_compare, NULL) PHP_FE(collator_get_default, NULL) PHP_FE(collator_set_default, NULL) + + /* character property functions */ + PHP_FE(unicode_is_lower, NULL) + PHP_FE(unicode_is_upper, NULL) + PHP_FE(unicode_is_digit, NULL) + PHP_FE(unicode_is_alpha, NULL) + PHP_FE(unicode_is_alnum, NULL) + PHP_FE(unicode_is_xdigit, NULL) + PHP_FE(unicode_is_punct, NULL) + PHP_FE(unicode_is_graph, NULL) + PHP_FE(unicode_is_blank, NULL) + PHP_FE(unicode_is_space, NULL) + PHP_FE(unicode_is_cntrl, NULL) + PHP_FE(unicode_is_print, NULL) + { NULL, NULL, NULL } }; /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php