helly Sat Mar 5 06:38:29 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/spl spl_array.c
/php-src/ext/spl/tests array_014.phpt
Log:
- MFH
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.49.2.4&r2=1.49.2.5&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.49.2.4
php-src/ext/spl/spl_array.c:1.49.2.5
--- php-src/ext/spl/spl_array.c:1.49.2.4 Thu Mar 3 05:45:42 2005
+++ php-src/ext/spl/spl_array.c Sat Mar 5 06:38:29 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.49.2.4 2005/03/03 10:45:42 helly Exp $ */
+/* $Id: spl_array.c,v 1.49.2.5 2005/03/05 11:38:29 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -806,16 +806,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(zend_exception_get_default(), 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.1.2.3&r2=1.1.2.4&ty=u
Index: php-src/ext/spl/tests/array_014.phpt
diff -u php-src/ext/spl/tests/array_014.phpt:1.1.2.3
php-src/ext/spl/tests/array_014.phpt:1.1.2.4
--- php-src/ext/spl/tests/array_014.phpt:1.1.2.3 Thu Mar 3 05:45:42 2005
+++ php-src/ext/spl/tests/array_014.phpt Sat Mar 5 06:38:29 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)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php