1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 01:18:19 +02:00

Proper ICU version check for restriction levels availability

This commit is contained in:
Anatol Belski
2017-10-30 18:21:14 +01:00
parent c35f69327c
commit 3ce3e96af3
5 changed files with 10 additions and 2 deletions
@@ -84,9 +84,11 @@ ZEND_BEGIN_ARG_INFO_EX(spoofchecker_are_confusable, 0, 0, 2)
ZEND_ARG_INFO(1, error)
ZEND_END_ARG_INFO()
#if U_ICU_VERSION_MAJOR_NUM >= 51
ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_restriction_level, 0, 0, 1)
ZEND_ARG_INFO(0, level)
ZEND_END_ARG_INFO()
#endif
/* }}} */
@@ -100,7 +102,9 @@ zend_function_entry Spoofchecker_class_functions[] = {
PHP_ME(Spoofchecker, areConfusable, spoofchecker_are_confusable, ZEND_ACC_PUBLIC)
PHP_ME(Spoofchecker, setAllowedLocales, spoofchecker_set_allowed_locales, ZEND_ACC_PUBLIC)
PHP_ME(Spoofchecker, setChecks, spoofchecker_set_checks, ZEND_ACC_PUBLIC)
#if U_ICU_VERSION_MAJOR_NUM >= 51
PHP_ME(Spoofchecker, setRestrictionLevel, spoofchecker_set_restriction_level, ZEND_ACC_PUBLIC)
#endif
PHP_FE_END
};
/* }}} */
+1 -1
View File
@@ -78,7 +78,7 @@ extern zend_class_entry *Spoofchecker_ce_ptr;
RETURN_FALSE; \
} \
#if U_ICU_VERSION_MAJOR_NUM >= 58
#if U_ICU_VERSION_MAJOR_NUM >= 51
#define SPOOFCHECKER_DEFAULT_RESTRICTION_LEVEL USPOOF_HIGHLY_RESTRICTIVE
#endif
+1 -1
View File
@@ -43,7 +43,7 @@ PHP_METHOD(Spoofchecker, __construct)
co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
INTL_METHOD_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
#if U_ICU_VERSION_MAJOR_NUM >= 58
#if U_ICU_VERSION_MAJOR_NUM >= 51
/* TODO save it into the object for further suspiction check comparison. */
/* ICU 58 removes WSC and MSC handling. However there are restriction
levels as defined in
@@ -134,6 +134,7 @@ PHP_METHOD(Spoofchecker, setChecks)
}
/* }}} */
#if U_ICU_VERSION_MAJOR_NUM >= 53
/* {{{ proto void Spoofchecker::setRestrictionLevel( int $restriction_level )
* Set the loosest restriction level allowed for strings.
*/
@@ -163,6 +164,7 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel)
uspoof_setRestrictionLevel(co->uspoof, (URestrictionLevel)level);
}
/* }}} */
#endif
/*
* Local variables:
@@ -23,6 +23,8 @@ PHP_METHOD(Spoofchecker, isSuspicious);
PHP_METHOD(Spoofchecker, areConfusable);
PHP_METHOD(Spoofchecker, setAllowedLocales);
PHP_METHOD(Spoofchecker, setChecks);
#if U_ICU_VERSION_MAJOR_NUM >= 51
PHP_METHOD(Spoofchecker, setRestrictionLevel);
#endif
#endif // SPOOFCHECKER_MAIN_H