mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Implement C/POSIX migration functions.
This commit is contained in:
parent
675ecc637b
commit
f0640426cb
2 changed files with 100 additions and 0 deletions
|
@ -18,7 +18,91 @@
|
|||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "php_unicode.h"
|
||||
#include "zend_unicode.h"
|
||||
#include "php_property.h"
|
||||
|
||||
void php_register_unicode_iterators(TSRMLS_D);
|
||||
|
||||
|
@ -246,6 +247,21 @@ zend_function_entry unicode_functions[] = {
|
|||
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 }
|
||||
};
|
||||
/* }}} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue