From: Ilia Alshanetsky Date: Thu, 8 Jan 2009 00:41:33 +0000 (+0000) Subject: MFB: Simplify parameter parsing X-Git-Tag: php-5.4.0alpha1~191^2~4598 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1691839ebff5c0ad21f60adfd79e1df4a6ddb21;p=php MFB: Simplify parameter parsing --- diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c index 9ddb0563fa..e77657714e 100644 --- a/ext/ereg/ereg.c +++ b/ext/ereg/ereg.c @@ -593,33 +593,25 @@ PHP_FUNCTION(eregi_replace) */ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase) { - zval **spliton, **str, **arg_count = NULL; + long count = -1; regex_t re; regmatch_t subs[1]; - char *strp, *endp; - int err, size, count = -1, copts = 0; - int argc = ZEND_NUM_ARGS(); + char *spliton, *str, *strp, *endp; + int spliton_len, str_len; + int err, size, copts = 0; - if (argc < 2 || argc > 3 || - zend_get_parameters_ex(argc, &spliton, &str, &arg_count) == FAILURE) { - WRONG_PARAM_COUNT; - } - - if (argc > 2) { - convert_to_long_ex(arg_count); - count = Z_LVAL_PP(arg_count); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &spliton, &spliton_len, &str, &str_len, &count) == FAILURE) { + return; } - if (icase) + if (icase) { copts = REG_ICASE; + } - convert_to_string_ex(spliton); - convert_to_string_ex(str); - - strp = Z_STRVAL_PP(str); - endp = strp + Z_STRLEN_PP(str); + strp = str; + endp = strp + str_len; - err = regcomp(&re, Z_STRVAL_PP(spliton), REG_EXTENDED | copts); + err = regcomp(&re, spliton, REG_EXTENDED | copts); if (err) { php_ereg_eprint(err, &re); RETURN_FALSE;