Merge R_2_5
[m6w6/ext-http] / php_http_negotiate.c
index f0526dc5a1bd9c3a5ab9899471dd7184b730dbab..d2410f88651a7d8014e9ad68560e6716a3983ef6 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "php_http_api.h"
 
-static int php_http_negotiate_sort(const void *first, const void *second TSRMLS_DC)
+static int php_http_negotiate_sort(const void *first, const void *second)
 {
        zval result;
        Bucket *b1 = (Bucket *) first, *b2 = (Bucket *) second;
@@ -27,10 +27,10 @@ static int php_http_negotiate_sort(const void *first, const void *second TSRMLS_
 #define M_SEC 2
 #define M_ANY 1
 #define M_NOT 0
-#define M_ALL -1
+#define M_ALL ~0
 static inline unsigned php_http_negotiate_match(const char *param_str, size_t param_len, const char *supported_str, size_t supported_len, const char *sep_str, size_t sep_len)
 {
-       int match = M_NOT;
+       unsigned match = M_NOT;
 
        if (param_len == supported_len && !strncasecmp(param_str, supported_str, param_len)) {
                /* that was easy */
@@ -92,6 +92,7 @@ static int php_http_negotiate_reduce(zval *p, int num_args, va_list args, zend_h
        ZEND_HASH_FOREACH_END();
 
        if (q && Z_DVAL_P(q) > 0) {
+               Z_TRY_ADDREF_P(q);
                zend_hash_update(result, supported, q);
        }
 
@@ -99,7 +100,7 @@ static int php_http_negotiate_reduce(zval *p, int num_args, va_list args, zend_h
        return ZEND_HASH_APPLY_KEEP;
 }
 
-HashTable *php_http_negotiate(const char *value_str, size_t value_len, HashTable *supported, const char *primary_sep_str, size_t primary_sep_len TSRMLS_DC)
+HashTable *php_http_negotiate(const char *value_str, size_t value_len, HashTable *supported, const char *primary_sep_str, size_t primary_sep_len)
 {
        HashTable *result = NULL;
 
@@ -114,7 +115,7 @@ HashTable *php_http_negotiate(const char *value_str, size_t value_len, HashTable
                php_http_params_opts_default_get(&opts);
                opts.input.str = estrndup(value_str, value_len);
                opts.input.len = value_len;
-               php_http_params_parse(&params, &opts TSRMLS_CC);
+               php_http_params_parse(&params, &opts);
                efree(opts.input.str);
 
                array_init(&arr);
@@ -131,6 +132,10 @@ HashTable *php_http_negotiate(const char *value_str, size_t value_len, HashTable
                                q = 1.0 - ++i / 100.0;
                        }
 
+#if 0
+                       fprintf(stderr, "Q: %s=%1.3f\n", key.key->val, q);
+#endif
+
                        if (key.key) {
                                add_assoc_double_ex(&arr, key.key->val, key.key->len, q);
                        } else {