cvs: php-src /ext/spl spl_array.c /ext/spl/tests array_014.phpt
| From: | Marcus Boerger | Date: | Sat, 05 Mar 2005 11:35:13 +0000 |
| Subject: | cvs: php-src /ext/spl spl_array.c /ext/spl/tests array_014.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-30721@lists.php.net to get a copy of this message | ||
helly Sat Mar 5 06:35:13 2005 EDT
Modified files:
/php-src/ext/spl spl_array.c
/php-src/ext/spl/tests array_014.phpt
Log:
- Negative seeking is not supported
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.60&r2=1.61&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.60 php-src/ext/spl/spl_array.c:1.61
--- php-src/ext/spl/spl_array.c:1.60 Thu Mar 3 05:35:33 2005
+++ php-src/ext/spl/spl_array.c Sat Mar 5 06:35:11 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.60 2005/03/03 10:35:33 helly Exp $ */
+/* $Id: spl_array.c,v 1.61 2005/03/05 11:35:11 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -813,16 +813,19 @@
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);
http://cvs.php.net/diff.php/php-src/ext/spl/tests/array_014.phpt?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/spl/tests/array_014.phpt
diff -u php-src/ext/spl/tests/array_014.phpt:1.4 php-src/ext/spl/tests/array_014.phpt:1.5
--- php-src/ext/spl/tests/array_014.phpt:1.4 Thu Mar 3 05:48:02 2005
+++ php-src/ext/spl/tests/array_014.phpt Sat Mar 5 06:35:13 2005
@@ -11,8 +11,16 @@
var_dump($it->current());
$it->seek(4);
var_dump($it->current());
-$it->seek(-1);
-var_dump($it->current());
+try
+{
+ $it->seek(-1);
+ var_dump($it->current());
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
try
{
$it->seek(12);
@@ -37,7 +45,7 @@
int(11)
int(5)
int(4)
-int(0)
+Seek position -1 is out of range
Seek position 12 is out of range
int(0)
int(1)