summaryrefslogtreecommitdiff
path: root/ext/intl/breakiterator/breakiterator_methods.cpp
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-06-22 18:28:19 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-06-22 18:52:06 +0200
commit77daa3482d5592181560e0e6076c1e3291620e7b (patch)
treea38cf12c807131552628a2f278dcebbc7f39979f /ext/intl/breakiterator/breakiterator_methods.cpp
parent0a7ae87e91368fe17c52767cfb31dabf3a94e38f (diff)
downloadphp-git-77daa3482d5592181560e0e6076c1e3291620e7b.tar.gz
BreakIterator::getPartsIterator: new optional arg
Can take one of: * IntlPartsIterator::KEY_SEQUENTIAL (keys are 0, 1, ...) * IntlPartsIterator::KEY_LEFT (keys are left boundaries) * IntlPartsIterator::KEY_LEFT (keys are right boundaries) The default is IntlPartsIterator::KEY_SEQUENTIAL (the previous behavior).
Diffstat (limited to 'ext/intl/breakiterator/breakiterator_methods.cpp')
-rw-r--r--ext/intl/breakiterator/breakiterator_methods.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp
index e9e6b19ba3..7b502528f3 100644
--- a/ext/intl/breakiterator/breakiterator_methods.cpp
+++ b/ext/intl/breakiterator/breakiterator_methods.cpp
@@ -384,18 +384,28 @@ U_CFUNC PHP_FUNCTION(breakiter_get_locale)
U_CFUNC PHP_FUNCTION(breakiter_get_parts_iterator)
{
+ long key_type = 0;
BREAKITER_METHOD_INIT_VARS;
object = getThis();
- if (zend_parse_parameters_none() == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &key_type) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "breakiter_get_parts_iterator: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (key_type != PARTS_ITERATOR_KEY_SEQUENTIAL
+ && key_type != PARTS_ITERATOR_KEY_LEFT
+ && key_type != PARTS_ITERATOR_KEY_RIGHT) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "breakiter_get_parts_iterator: bad arguments", 0 TSRMLS_CC);
+ "breakiter_get_parts_iterator: bad key type", 0 TSRMLS_CC);
RETURN_FALSE;
}
BREAKITER_METHOD_FETCH_OBJECT;
- IntlIterator_from_BreakIterator_parts(object, return_value TSRMLS_CC);
+ IntlIterator_from_BreakIterator_parts(
+ object, return_value, (parts_iter_key_type)key_type TSRMLS_CC);
}
U_CFUNC PHP_FUNCTION(breakiter_get_error_code)