From 83a0665455099206d7a607eaea94a644997ae28d Mon Sep 17 00:00:00 2001 From: foobar Date: Wed, 11 Sep 2002 15:29:50 +0000 Subject: Fix bug: #19355 (the parameter is optional) --- ext/iconv/iconv.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 62951671d7..0018e09399 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -367,35 +367,28 @@ PHP_FUNCTION(iconv_set_encoding) Get internal encoding and output encoding for ob_iconv_handler() */ PHP_FUNCTION(iconv_get_encoding) { - zval **type; - int argc = ZEND_NUM_ARGS(); - - if (argc < 0 || argc > 1 || zend_get_parameters_ex(1, &type) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(type); - - if (argc == 0 || !strcasecmp("all", Z_STRVAL_PP(type))) { + char *type = "all"; + int type_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE) + return; + + if (!strcasecmp("all", type)) { if (array_init(return_value) == FAILURE) { RETURN_FALSE; } - add_assoc_string(return_value, "input_encoding", - ICONVG(input_encoding), 1); - add_assoc_string(return_value, "output_encoding", - ICONVG(output_encoding), 1); - add_assoc_string(return_value, "internal_encoding", - ICONVG(internal_encoding), 1); - } else if (!strcasecmp("input_encoding", Z_STRVAL_PP(type))) { + add_assoc_string(return_value, "input_encoding", ICONVG(input_encoding), 1); + add_assoc_string(return_value, "output_encoding", ICONVG(output_encoding), 1); + add_assoc_string(return_value, "internal_encoding", ICONVG(internal_encoding), 1); + } else if (!strcasecmp("input_encoding", type)) { RETVAL_STRING(ICONVG(input_encoding), 1); - } else if (!strcasecmp("output_encoding", Z_STRVAL_PP(type))) { + } else if (!strcasecmp("output_encoding", type)) { RETVAL_STRING(ICONVG(output_encoding), 1); - } else if (!strcasecmp("internal_encoding", Z_STRVAL_PP(type))) { + } else if (!strcasecmp("internal_encoding", type)) { RETVAL_STRING(ICONVG(internal_encoding), 1); } else { RETURN_FALSE; } - } /* }}} */ -- cgit v1.2.1