]> granicus.if.org Git - php/commitdiff
Implement C/POSIX migration functions.
authorAndrei Zmievski <andrei@php.net>
Tue, 2 May 2006 21:39:15 +0000 (21:39 +0000)
committerAndrei Zmievski <andrei@php.net>
Tue, 2 May 2006 21:39:15 +0000 (21:39 +0000)
ext/unicode/property.c
ext/unicode/unicode.c

index e7f411afb9551c5b77214cd58507ff0f6763a7df..c9ec9652e004a32a74d8375ca74231270ff0cb9e 100644 (file)
 
 #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);
+}
 
 
 /*
index 4f93e116f33ba201ae77967d9a1a38f5ed1b7098..8ab19ec8993241dacebac61148df8a7ffd3967ac 100644 (file)
@@ -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 }
 };
 /* }}} */