diff options
author | foobar <sniper@php.net> | 2002-09-11 15:29:50 +0000 |
---|---|---|
committer | foobar <sniper@php.net> | 2002-09-11 15:29:50 +0000 |
commit | 83a0665455099206d7a607eaea94a644997ae28d (patch) | |
tree | 3a7db8eea5e2d6d932a54bf3038acd2dbd2d8b51 | |
parent | 1f58a1260187dc061267a7e8ee4a92257f9c349e (diff) | |
download | php-git-83a0665455099206d7a607eaea94a644997ae28d.tar.gz |
Fix bug: #19355 (the parameter is optional)
-rw-r--r-- | ext/iconv/iconv.c | 33 |
1 files 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; } - } /* }}} */ |