char *str, *encoding;
long from, len;
int mblen, str_len, encoding_len;
+ zval **z_len = NULL;
mbfl_string string, result, *ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls", &str, &str_len, &from, &len, &encoding, &encoding_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|Zs", &str, &str_len, &from, &z_len, &encoding, &encoding_len) == FAILURE) {
return;
}
string.val = (unsigned char *)str;
string.len = str_len;
- if (argc < 3) {
+ if (argc < 3 || Z_TYPE_PP(z_len) == IS_NULL) {
len = str_len;
+ } else {
+ convert_to_long_ex(z_len);
+ len = Z_LVAL_PP(z_len);
}
/* measures length */
char *encoding;
long from, len;
int encoding_len;
+ zval **z_len = NULL;
mbfl_string string, result, *ret;
mbfl_string_init(&string);
string.no_language = MBSTRG(language);
string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls", (char **)&string.val, (int **)&string.len, &from, &len, &encoding, &encoding_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|Zs", (char **)&string.val, (int **)&string.len, &from, &z_len, &encoding, &encoding_len) == FAILURE) {
return;
}
}
}
- if (argc < 3) {
+ if (argc < 3 || Z_TYPE_PP(z_len) == IS_NULL) {
len = string.len;
+ } else {
+ convert_to_long_ex(z_len);
+ len = Z_LVAL_PP(z_len);
}
/* if "from" position is negative, count start position from the end