helly           Sun Jan  1 19:51:17 2006 UTC

  Modified files:              (Branch: PHP_5_1)
    /php-src/ext/spl    spl_iterators.c 
  Log:
  - key() might be optional
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.18&r2=1.73.2.19&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.18 
php-src/ext/spl/spl_iterators.c:1.73.2.19
--- php-src/ext/spl/spl_iterators.c:1.73.2.18   Sun Jan  1 19:48:11 2006
+++ php-src/ext/spl/spl_iterators.c     Sun Jan  1 19:51:17 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.73.2.18 2006/01/01 19:48:11 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.19 2006/01/01 19:51:17 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -2049,17 +2049,21 @@
                iter->funcs->rewind(iter TSRMLS_CC);
        }
        while (iter->funcs->valid(iter TSRMLS_CC) == SUCCESS) {
-               key_type = iter->funcs->get_current_key(iter, &str_key, 
&str_key_len, &int_key TSRMLS_CC);
                iter->funcs->get_current_data(iter, &data TSRMLS_CC);
                (*data)->refcount++;
-               switch(key_type) {
-                       case HASH_KEY_IS_STRING:
-                               add_assoc_zval_ex(return_value, str_key, 
str_key_len, *data);
-                               efree(str_key);
-                               break;
-                       case HASH_KEY_IS_LONG:
-                               add_index_zval(return_value, int_key, *data);
-                               break;
+               if (iter->funcs->get_current_key) {
+                       key_type = iter->funcs->get_current_key(iter, &str_key, 
&str_key_len, &int_key TSRMLS_CC);
+                       switch(key_type) {
+                               case HASH_KEY_IS_STRING:
+                                       add_assoc_zval_ex(return_value, 
str_key, str_key_len, *data);
+                                       efree(str_key);
+                                       break;
+                               case HASH_KEY_IS_LONG:
+                                       add_index_zval(return_value, int_key, 
*data);
+                                       break;
+                       }
+               } else {
+                       add_next_index_zval(return_value, *data);
                }
                iter->funcs->move_forward(iter TSRMLS_CC);
        }

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

Reply via email to