X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_querystring.c;h=5f4eff81a9a101414d4ffed647fcc9ae6c9a4f12;hp=bd04f5092f9b233a9a53851f75858d4d668c8362;hb=1f37d09e4c7f55cf6f2c3c10ea3ec2424a482671;hpb=b2773ab559878238bd024c4bbebe5825cc38ad85 diff --git a/php_http_querystring.c b/php_http_querystring.c index bd04f50..5f4eff8 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -16,6 +16,9 @@ #include #ifdef PHP_HTTP_HAVE_ICONV +# ifndef HAVE_ICONV +# define HAVE_ICONV 1 +# endif # undef PHP_ATOM_INC # include #endif @@ -67,7 +70,7 @@ static inline void php_http_querystring_get(zval *instance, int type, char *name convert_to_explicit_type(&tmp, type); RETVAL_ZVAL(&tmp, 0, 0); } else { - RETVAL_ZVAL_FAST(arrval); + RETVAL_ZVAL(arrval, 1, 0); } if (del) { @@ -79,7 +82,7 @@ static inline void php_http_querystring_get(zval *instance, int type, char *name zval_ptr_dtor(&delarr); } } else if(defval) { - RETURN_ZVAL_FAST(defval); + RETURN_ZVAL(defval, 1, 0); } } @@ -178,7 +181,7 @@ ZEND_RESULT_CODE php_http_querystring_parse(HashTable *ht, const char *str, size opts.val = vsepp; opts.flags = PHP_HTTP_PARAMS_QUERY; - if (SUCCESS == php_http_ini_entry(ZEND_STRL("arg_separator.input"), &asi_str, &asi_len, 0 TSRMLS_CC) && asi_len) { + if (SUCCESS == php_http_ini_entry(ZEND_STRL("arg_separator.input"), &asi_str, &asi_len, 0) && asi_len) { zval arr; array_init_size(&arr, asi_len); @@ -329,7 +332,7 @@ PHP_METHOD(HttpQueryString, __construct) zval *params = NULL; zend_error_handling zeh; - php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", ¶ms), invalid_arg, return); + php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z", ¶ms), invalid_arg, return); zend_replace_error_handling(EH_THROW, php_http_exception_bad_querystring_class_entry, &zeh); php_http_querystring_set(getThis(), params, 0); @@ -350,7 +353,7 @@ PHP_METHOD(HttpQueryString, getGlobalInstance) zend_string_release(zs); if (Z_TYPE_P(instance) == IS_OBJECT) { - RETVAL_ZVAL_FAST(instance); + RETVAL_ZVAL(instance, 1, 0); } else if ((_GET = php_http_env_get_superglobal(ZEND_STRL("_GET")))) { ZVAL_OBJ(return_value, php_http_querystring_object_new(php_http_querystring_class_entry)); @@ -399,7 +402,7 @@ PHP_METHOD(HttpQueryString, toArray) } zqa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &zqa_tmp); - RETURN_ZVAL_FAST(zqa); + RETURN_ZVAL(zqa, 1, 0); } ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_get, 0, 0, 0) @@ -529,7 +532,7 @@ PHP_METHOD(HttpQueryString, xlate) ); php_http_querystring_set(getThis(), &na, 0); - RETVAL_ZVAL_FAST(getThis()); + RETVAL_ZVAL(getThis(), 1, 0); zval_ptr_dtor(&na); } @@ -580,7 +583,7 @@ PHP_METHOD(HttpQueryString, offsetGet) if (Z_TYPE_P(qa) == IS_ARRAY) { if ((value = zend_symtable_find(Z_ARRVAL_P(qa), offset))) { - RETVAL_ZVAL_FAST(value); + RETVAL_ZVAL(value, 1, 0); } } } @@ -592,16 +595,21 @@ ZEND_END_ARG_INFO(); PHP_METHOD(HttpQueryString, offsetSet) { zend_string *offset; - zval *value, param; + zval *value, param, znull; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz", &offset, &value)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "Sz", &offset, &value)) { return; } - array_init(¶m); + array_init_size(¶m, 1); + /* unset first */ + ZVAL_NULL(&znull); + zend_symtable_update(Z_ARRVAL(param), offset, &znull); + php_http_querystring_set(getThis(), ¶m, QS_MERGE); + /* then update, else QS_MERGE would merge sub-arrrays */ Z_TRY_ADDREF_P(value); zend_symtable_update(Z_ARRVAL(param), offset, value); - php_http_querystring_set(getThis(), ¶m, 0); + php_http_querystring_set(getThis(), ¶m, QS_MERGE); zval_ptr_dtor(¶m); } @@ -636,7 +644,7 @@ PHP_METHOD(HttpQueryString, offsetUnset) zend_string *offset; zval param, znull; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &offset)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S", &offset)) { return; }