Diff for /embedaddon/php/ext/standard/array.c between versions 1.1.1.2 and 1.1.1.4

version 1.1.1.2, 2012/05/29 12:34:43 version 1.1.1.4, 2013/10/14 08:02:34
Line 2 Line 2
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | PHP Version 5                                                        |     | PHP Version 5                                                        |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
   | Copyright (c) 1997-2012 The PHP Group                                |   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |     | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |     | that is bundled with this package in the file LICENSE, and is        |
Line 352  PHP_FUNCTION(count) Line 352  PHP_FUNCTION(count)
   
 /* Numbers are always smaller than strings int this function as it  /* Numbers are always smaller than strings int this function as it
  * anyway doesn't make much sense to compare two different data types.   * anyway doesn't make much sense to compare two different data types.
 * This keeps it consistant and simple. * This keeps it consistent and simple.
  *   *
  * This is not correct any more, depends on what compare_func is set to.   * This is not correct any more, depends on what compare_func is set to.
  */   */
Line 1053  PHP_FUNCTION(max) Line 1053  PHP_FUNCTION(max)
 static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive TSRMLS_DC) /* {{{ */  static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive TSRMLS_DC) /* {{{ */
 {  {
         zval **args[3],                 /* Arguments to userland function */          zval **args[3],                 /* Arguments to userland function */
                  *retval_ptr,               /* Return value - unused */                  *retval_ptr = NULL,               /* Return value - unused */
                   *key=NULL;            /* Entry key */                    *key=NULL;            /* Entry key */
         char  *string_key;          char  *string_key;
         uint   string_key_len;          uint   string_key_len;
         ulong  num_key;          ulong  num_key;
         HashPosition pos;  
   
         /* Set up known arguments */          /* Set up known arguments */
         args[1] = &key;          args[1] = &key;
Line 1067  static int php_array_walk(HashTable *target_hash, zval Line 1066  static int php_array_walk(HashTable *target_hash, zval
                 Z_ADDREF_P(userdata);                  Z_ADDREF_P(userdata);
         }          }
   
         zend_hash_internal_pointer_reset_ex(target_hash, &pos);  
   
         BG(array_walk_fci).retval_ptr_ptr = &retval_ptr;          BG(array_walk_fci).retval_ptr_ptr = &retval_ptr;
         BG(array_walk_fci).param_count = userdata ? 3 : 2;          BG(array_walk_fci).param_count = userdata ? 3 : 2;
         BG(array_walk_fci).params = args;          BG(array_walk_fci).params = args;
         BG(array_walk_fci).no_separation = 0;          BG(array_walk_fci).no_separation = 0;
        
         /* Iterate through hash */          /* Iterate through hash */
        while (!EG(exception) && zend_hash_get_current_data_ex(target_hash, (void **)&args[0], &pos) == SUCCESS) {        zend_hash_internal_pointer_reset(target_hash);
         while (!EG(exception) && zend_hash_get_current_data(target_hash, (void **)&args[0]) == SUCCESS) {
                 if (recursive && Z_TYPE_PP(args[0]) == IS_ARRAY) {                  if (recursive && Z_TYPE_PP(args[0]) == IS_ARRAY) {
                         HashTable *thash;                          HashTable *thash;
                         zend_fcall_info orig_array_walk_fci;                          zend_fcall_info orig_array_walk_fci;
Line 1107  static int php_array_walk(HashTable *target_hash, zval Line 1105  static int php_array_walk(HashTable *target_hash, zval
                         MAKE_STD_ZVAL(key);                          MAKE_STD_ZVAL(key);
   
                         /* Set up the key */                          /* Set up the key */
                        switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 0, &pos)) {                        switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 0, NULL)) {
                                 case HASH_KEY_IS_LONG:                                  case HASH_KEY_IS_LONG:
                                         Z_TYPE_P(key) = IS_LONG;                                          Z_TYPE_P(key) = IS_LONG;
                                         Z_LVAL_P(key) = num_key;                                          Z_LVAL_P(key) = num_key;
Line 1135  static int php_array_walk(HashTable *target_hash, zval Line 1133  static int php_array_walk(HashTable *target_hash, zval
                         zval_ptr_dtor(&key);                          zval_ptr_dtor(&key);
                         key = NULL;                          key = NULL;
                 }                  }
                zend_hash_move_forward_ex(target_hash, &pos);                zend_hash_move_forward(target_hash);
         }          }
   
         if (userdata) {          if (userdata) {
Line 2879  static int zval_compare(zval **a, zval **b TSRMLS_DC)  Line 2877  static int zval_compare(zval **a, zval **b TSRMLS_DC) 
 static int zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */  static int zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */
 {  {
         zval **args[2];          zval **args[2];
        zval *retval_ptr;        zval *retval_ptr = NULL;
   
         args[0] = (zval **) a;          args[0] = (zval **) a;
         args[1] = (zval **) b;          args[1] = (zval **) b;
Line 2998  static void php_array_intersect(INTERNAL_FUNCTION_PARA Line 2996  static void php_array_intersect(INTERNAL_FUNCTION_PARA
         char *param_spec;          char *param_spec;
         zend_fcall_info fci1, fci2;          zend_fcall_info fci1, fci2;
         zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;          zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;
        zend_fcall_info *fci_key, *fci_data;        zend_fcall_info *fci_key = NULL, *fci_data;
        zend_fcall_info_cache *fci_key_cache, *fci_data_cache;        zend_fcall_info_cache *fci_key_cache = NULL, *fci_data_cache;
         PHP_ARRAY_CMP_FUNC_VARS;          PHP_ARRAY_CMP_FUNC_VARS;
   
         int (*intersect_key_compare_func)(const void *, const void * TSRMLS_DC);          int (*intersect_key_compare_func)(const void *, const void * TSRMLS_DC);
Line 3416  static void php_array_diff(INTERNAL_FUNCTION_PARAMETER Line 3414  static void php_array_diff(INTERNAL_FUNCTION_PARAMETER
         char *param_spec;          char *param_spec;
         zend_fcall_info fci1, fci2;          zend_fcall_info fci1, fci2;
         zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;          zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache;
        zend_fcall_info *fci_key, *fci_data;        zend_fcall_info *fci_key = NULL, *fci_data;
        zend_fcall_info_cache *fci_key_cache, *fci_data_cache;        zend_fcall_info_cache *fci_key_cache = NULL, *fci_data_cache;
         PHP_ARRAY_CMP_FUNC_VARS;          PHP_ARRAY_CMP_FUNC_VARS;
   
         int (*diff_key_compare_func)(const void *, const void * TSRMLS_DC);          int (*diff_key_compare_func)(const void *, const void * TSRMLS_DC);
Line 4021  PHP_FUNCTION(array_sum) Line 4019  PHP_FUNCTION(array_sum)
                  **entry,                   **entry,
                  entry_n;                   entry_n;
         HashPosition pos;          HashPosition pos;
         double dval;  
   
         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &input) == FAILURE) {          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &input) == FAILURE) {
                 return;                  return;
Line 4039  PHP_FUNCTION(array_sum) Line 4036  PHP_FUNCTION(array_sum)
                 entry_n = **entry;                  entry_n = **entry;
                 zval_copy_ctor(&entry_n);                  zval_copy_ctor(&entry_n);
                 convert_scalar_to_number(&entry_n TSRMLS_CC);                  convert_scalar_to_number(&entry_n TSRMLS_CC);
                fast_add_function(return_value, return_value, &entry_n TSRMLS_CC);
                if (Z_TYPE(entry_n) == IS_LONG && Z_TYPE_P(return_value) == IS_LONG) { 
                        dval = (double)Z_LVAL_P(return_value) + (double)Z_LVAL(entry_n); 
                        if ( (double)LONG_MIN <= dval && dval <= (double)LONG_MAX ) { 
                                Z_LVAL_P(return_value) += Z_LVAL(entry_n); 
                                continue; 
                        } 
                } 
                convert_to_double(return_value); 
                convert_to_double(&entry_n); 
                Z_DVAL_P(return_value) += Z_DVAL(entry_n); 
         }          }
 }  }
 /* }}} */  /* }}} */

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>