helly           Tue Mar  1 05:09:05 2005 EDT

  Modified files:              (Branch: PHP_5_0)
    /php-src/ext/spl    spl_array.c 
  Log:
  - MFH
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.49.2.2&r2=1.49.2.3&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.49.2.2 
php-src/ext/spl/spl_array.c:1.49.2.3
--- php-src/ext/spl/spl_array.c:1.49.2.2        Mon Jan 24 16:38:29 2005
+++ php-src/ext/spl/spl_array.c Tue Mar  1 05:09:05 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c,v 1.49.2.2 2005/01/24 21:38:29 helly Exp $ */
+/* $Id: spl_array.c,v 1.49.2.3 2005/03/01 10:09:05 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -713,10 +713,11 @@
  Seek to position. */
 SPL_METHOD(Array, seek)
 {
-       long position;
+       long opos, position;
        zval *object = getThis();
        spl_array_object *intern = 
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
        HashTable *aht = HASH_OF(intern->array);
+       int result;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == 
FAILURE) {
                return;
@@ -729,7 +730,17 @@
 
        zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
        
-       while (position-- > 0 && spl_array_next(intern TSRMLS_CC) == SUCCESS);
+       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 */
+               }
+       }
+       zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC, 
"Seek position %ld is out of range", opos);
 } /* }}} */
 
 int spl_array_object_count_elements(zval *object, long *count TSRMLS_DC) /* 
{{{ */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to