Merge branch 'R_2_0'
authorMichael Wallner <mike@php.net>
Thu, 10 Jul 2014 14:39:41 +0000 (16:39 +0200)
committerMichael Wallner <mike@php.net>
Thu, 10 Jul 2014 14:39:41 +0000 (16:39 +0200)
1  2 
php_http_misc.h

diff --combined php_http_misc.h
index 0763476544bc7868cc595eba910542d0938fb1ef,e7d22585f02eaa0abcc06784fff8d71cae075bd2..b8c54faba2b51da8839436187f65c423308f98cf
@@@ -140,42 -140,37 +140,37 @@@ static inline const char *php_http_loca
                Z_ARRVAL_P(zv) = (ht); \
        }
  
- static inline zval *php_http_ztyp(int type, zval *z)
+ static inline zval *php_http_zconv(int type, zval *z)
  {
-       SEPARATE_ARG_IF_REF(z);
-       if (Z_TYPE_P(z) != type) {
-               switch (type) {
-                       case IS_NULL:   convert_to_null_ex(&z);         break;
-                       case IS_BOOL:   convert_to_boolean_ex(&z);      break;
-                       case IS_LONG:   convert_to_long_ex(&z);         break;
-                       case IS_DOUBLE: convert_to_double_ex(&z);       break;
-                       case IS_STRING: convert_to_string_ex(&z);       break;
-                       case IS_ARRAY:  convert_to_array_ex(&z);        break;
-                       case IS_OBJECT: convert_to_object_ex(&z);       break;
-               }
+       switch (type) {
+               case IS_NULL:   convert_to_null_ex(&z);         break;
+               case IS_BOOL:   convert_to_boolean_ex(&z);      break;
+               case IS_LONG:   convert_to_long_ex(&z);         break;
+               case IS_DOUBLE: convert_to_double_ex(&z);       break;
+               case IS_STRING: convert_to_string_ex(&z);       break;
+               case IS_ARRAY:  convert_to_array_ex(&z);        break;
+               case IS_OBJECT: convert_to_object_ex(&z);       break;
        }
        return z;
  }
  
+ static inline zval *php_http_ztyp(int type, zval *z)
+ {
+       SEPARATE_ARG_IF_REF(z);
+       return (Z_TYPE_P(z) == type) ? z : php_http_zconv(type, z);
+ }
  static inline zval *php_http_zsep(zend_bool add_ref, int type, zval *z)
  {
        if (add_ref) {
                Z_ADDREF_P(z);
        }
        if (Z_TYPE_P(z) != type) {
-               switch (type) {
-                       case IS_NULL:   convert_to_null_ex(&z);         break;
-                       case IS_BOOL:   convert_to_boolean_ex(&z);      break;
-                       case IS_LONG:   convert_to_long_ex(&z);         break;
-                       case IS_DOUBLE: convert_to_double_ex(&z);       break;
-                       case IS_STRING: convert_to_string_ex(&z);       break;
-                       case IS_ARRAY:  convert_to_array_ex(&z);        break;
-                       case IS_OBJECT: convert_to_object_ex(&z);       break;
-               }
+               return php_http_zconv(type, z);
        } else {
                SEPARATE_ZVAL_IF_NOT_REF(&z);
+               return z;
        }
-       return z;
  }
  
  static inline STATUS php_http_ini_entry(const char *name_str, size_t name_len, const char **value_str, size_t *value_len, zend_bool orig TSRMLS_DC)
  #define PHP_RSHUTDOWN_CALL(func) PHP_RSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
  
  /* ARRAYS */
 +
 +#ifndef HASH_KEY_NON_EXISTENT
 +#     define HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTANT
 +#endif
 +
  PHP_HTTP_API unsigned php_http_array_list(HashTable *ht TSRMLS_DC, unsigned argc, ...);
  
  typedef struct php_http_array_hashkey {
@@@ -296,10 -286,13 +291,13 @@@ static inline void php_http_array_hashk
                        zend_hash_move_forward_ex(hash, &pos))
  
  #define array_copy(src, dst) zend_hash_copy(dst, src, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *))
- #define ARRAY_JOIN_STRONLY 1
- #define ARRAY_JOIN_PRETTIFY 2
+ #define array_copy_strings(src, dst) zend_hash_copy(dst, src, php_http_array_copy_strings, NULL, sizeof(zval *))
+ #define ARRAY_JOIN_STRONLY   0x01
+ #define ARRAY_JOIN_PRETTIFY  0x02
+ #define ARRAY_JOIN_STRINGIFY 0x04
  #define array_join(src, dst, append, flags) zend_hash_apply_with_arguments(src TSRMLS_CC, (append)?php_http_array_apply_append_func:php_http_array_apply_merge_func, 2, dst, (int)flags)
  
+ void php_http_array_copy_strings(void *zpp);
  int php_http_array_apply_append_func(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key);
  int php_http_array_apply_merge_func(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key);