summaryrefslogtreecommitdiff
path: root/ext/spl/spl_iterators.c
diff options
context:
space:
mode:
authorAaron Piotrowski <aaron@trowski.com>2016-06-10 22:02:23 -0500
committerAaron Piotrowski <aaron@trowski.com>2016-06-10 22:02:23 -0500
commite3c681aa5cc71122a8d2fae42e6513fc413ccac8 (patch)
tree5f1df62f7b666028edb0ee1adf083a52d63df45a /ext/spl/spl_iterators.c
parentfb4e3085cbaa76eb8f28eebf848a81d1c0190067 (diff)
parent792e89385ca6fc722a03590722eb7745a2374720 (diff)
downloadphp-git-e3c681aa5cc71122a8d2fae42e6513fc413ccac8.tar.gz
Merge branch 'master' into throw-error-in-extensions
Diffstat (limited to 'ext/spl/spl_iterators.c')
-rw-r--r--ext/spl/spl_iterators.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 0f99923492..2f711ca2a6 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
+ | Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -390,9 +390,11 @@ next_step:
}
}
}
- zend_iterator_dtor(iterator);
- zval_ptr_dtor(&object->iterators[object->level].zobject);
- object->level--;
+ if (object->level > 0) {
+ zend_iterator_dtor(iterator);
+ zval_ptr_dtor(&object->iterators[object->level].zobject);
+ object->level--;
+ }
} else {
return; /* done completeley */
}
@@ -1986,7 +1988,6 @@ SPL_METHOD(CallbackFilterIterator, accept)
zend_fcall_info *fci = &intern->u.cbfilter->fci;
zend_fcall_info_cache *fcc = &intern->u.cbfilter->fcc;
zval params[3];
- zval result;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2000,19 +2001,22 @@ SPL_METHOD(CallbackFilterIterator, accept)
ZVAL_COPY_VALUE(&params[1], &intern->current.key);
ZVAL_COPY_VALUE(&params[2], &intern->inner.zobject);
- fci->retval = &result;
+ fci->retval = return_value;
fci->param_count = 3;
fci->params = params;
fci->no_separation = 0;
- if (zend_call_function(fci, fcc) != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
+ if (zend_call_function(fci, fcc) != SUCCESS || Z_ISUNDEF_P(return_value)) {
RETURN_FALSE;
}
+
if (EG(exception)) {
- return;
+ RETURN_NULL();
}
- RETURN_ZVAL(&result, 1, 1);
+ /* zend_call_function may change args to IS_REF */
+ ZVAL_COPY_VALUE(&intern->current.data, &params[0]);
+ ZVAL_COPY_VALUE(&intern->current.key, &params[1]);
}
/* }}} */
@@ -2047,16 +2051,17 @@ SPL_METHOD(RegexIterator, accept)
{
case REGIT_MODE_MAX: /* won't happen but makes compiler happy */
case REGIT_MODE_MATCH:
+#ifdef PCRE_EXTRA_MARK
+ if (intern->u.regex.pce->extra) {
+ intern->u.regex.pce->extra->flags &= ~PCRE_EXTRA_MARK;
+ }
+#endif
count = pcre_exec(intern->u.regex.pce->re, intern->u.regex.pce->extra, ZSTR_VAL(subject), ZSTR_LEN(subject), 0, 0, NULL, 0);
RETVAL_BOOL(count >= 0);
break;
case REGIT_MODE_ALL_MATCHES:
case REGIT_MODE_GET_MATCH:
-//??? if (!use_copy) {
-//??? subject = estrndup(subject, subject_len);
-//??? use_copy = 1;
-//??? }
zval_ptr_dtor(&intern->current.data);
ZVAL_UNDEF(&intern->current.data);
php_pcre_match_impl(intern->u.regex.pce, ZSTR_VAL(subject), ZSTR_LEN(subject), &zcount,
@@ -2065,10 +2070,6 @@ SPL_METHOD(RegexIterator, accept)
break;
case REGIT_MODE_SPLIT:
-//??? if (!use_copy) {
-//??? subject = estrndup(subject, subject_len);
-//??? use_copy = 1;
-//??? }
zval_ptr_dtor(&intern->current.data);
ZVAL_UNDEF(&intern->current.data);
php_pcre_split_impl(intern->u.regex.pce, ZSTR_VAL(subject), ZSTR_LEN(subject), &intern->current.data, -1, intern->u.regex.preg_flags);
@@ -2314,10 +2315,7 @@ static void spl_dual_it_free_storage(zend_object *_object)
}
if (object->dit_type == DIT_CachingIterator || object->dit_type == DIT_RecursiveCachingIterator) {
- if (Z_TYPE(object->u.caching.zcache) != IS_UNDEF) {
- zval_ptr_dtor(&object->u.caching.zcache);
- //ZVAL_UNDEF(&object->u.caching.zcache);
- }
+ zval_ptr_dtor(&object->u.caching.zcache);
}
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
@@ -2641,7 +2639,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
ZVAL_DEREF(data);
Z_TRY_ADDREF_P(data);
- array_set_zval_key(HASH_OF(&intern->u.caching.zcache), key, data);
+ array_set_zval_key(Z_ARRVAL(intern->u.caching.zcache), key, data);
zval_ptr_dtor(data);
}
/* Recursion ? */
@@ -2706,7 +2704,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
static inline void spl_caching_it_rewind(spl_dual_it_object *intern)
{
spl_dual_it_rewind(intern);
- zend_hash_clean(HASH_OF(&intern->u.caching.zcache));
+ zend_hash_clean(Z_ARRVAL(intern->u.caching.zcache));
spl_caching_it_next(intern);
}
@@ -2827,7 +2825,7 @@ SPL_METHOD(CachingIterator, offsetSet)
if (Z_REFCOUNTED_P(value)) {
Z_ADDREF_P(value);
}
- zend_symtable_update(HASH_OF(&intern->u.caching.zcache), key, value);
+ zend_symtable_update(Z_ARRVAL(intern->u.caching.zcache), key, value);
}
/* }}} */
@@ -2850,7 +2848,7 @@ SPL_METHOD(CachingIterator, offsetGet)
return;
}
- if ((value = zend_symtable_find(HASH_OF(&intern->u.caching.zcache), key)) == NULL) {
+ if ((value = zend_symtable_find(Z_ARRVAL(intern->u.caching.zcache), key)) == NULL) {
zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(key));
return;
}
@@ -2878,7 +2876,7 @@ SPL_METHOD(CachingIterator, offsetUnset)
return;
}
- zend_symtable_del(HASH_OF(&intern->u.caching.zcache), key);
+ zend_symtable_del(Z_ARRVAL(intern->u.caching.zcache), key);
}
/* }}} */
@@ -2900,7 +2898,7 @@ SPL_METHOD(CachingIterator, offsetExists)
return;
}
- RETURN_BOOL(zend_symtable_exists(HASH_OF(&intern->u.caching.zcache), key));
+ RETURN_BOOL(zend_symtable_exists(Z_ARRVAL(intern->u.caching.zcache), key));
}
/* }}} */
@@ -2909,7 +2907,6 @@ SPL_METHOD(CachingIterator, offsetExists)
SPL_METHOD(CachingIterator, getCache)
{
spl_dual_it_object *intern;
- zval *value;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2922,9 +2919,7 @@ SPL_METHOD(CachingIterator, getCache)
return;
}
- value = &intern->u.caching.zcache;
- ZVAL_DEREF(value);
- ZVAL_COPY(return_value, value);
+ ZVAL_COPY(return_value, &intern->u.caching.zcache);
}
/* }}} */
@@ -2971,7 +2966,7 @@ SPL_METHOD(CachingIterator, setFlags)
}
if ((flags & CIT_FULL_CACHE) != 0 && (intern->u.caching.flags & CIT_FULL_CACHE) == 0) {
/* clear on (re)enable */
- zend_hash_clean(HASH_OF(&intern->u.caching.zcache));
+ zend_hash_clean(Z_ARRVAL(intern->u.caching.zcache));
}
intern->u.caching.flags = (intern->u.caching.flags & ~CIT_PUBLIC) | (flags & CIT_PUBLIC);
}
@@ -2994,7 +2989,7 @@ SPL_METHOD(CachingIterator, count)
return;
}
- RETURN_LONG(zend_hash_num_elements(HASH_OF(&intern->u.caching.zcache)));
+ RETURN_LONG(zend_hash_num_elements(Z_ARRVAL(intern->u.caching.zcache)));
}
/* }}} */