diff options
| author | Marcus Boerger <helly@php.net> | 2005-03-05 11:35:13 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2005-03-05 11:35:13 +0000 |
| commit | e4ce3e36efd5d2b9e9be66767db06c14d690b32a (patch) | |
| tree | c87629542d3afc31bd53ddf84b4927f4ff0e471d /ext/spl/spl_array.c | |
| parent | 7fc626f89bb165742a7dcb660774923505fc53a0 (diff) | |
| download | php-git-e4ce3e36efd5d2b9e9be66767db06c14d690b32a.tar.gz | |
- Negative seeking is not supported
Diffstat (limited to 'ext/spl/spl_array.c')
| -rwxr-xr-x | ext/spl/spl_array.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 20ceb691ae..c35f583aec 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -813,16 +813,19 @@ SPL_METHOD(Array, seek) return; } - zend_hash_internal_pointer_reset_ex(aht, &intern->pos); - opos = position; - while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS); - if (intern->pos && intern->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) { - /* fail */ - } else { - if (zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS) { - return; /* ok */ + if (position >= 0) { /* negative values are not supported */ + zend_hash_internal_pointer_reset_ex(aht, &intern->pos); + + while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS); + + if (intern->pos && intern->is_ref && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) { + /* fail */ + } else { + if (zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS) { + return; /* ok */ + } } } zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %ld is out of range", opos); |
