]> granicus.if.org Git - php/commitdiff
MFB: Simplify parameter parsing
authorIlia Alshanetsky <iliaa@php.net>
Thu, 8 Jan 2009 00:41:33 +0000 (00:41 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 8 Jan 2009 00:41:33 +0000 (00:41 +0000)
ext/ereg/ereg.c

index 9ddb0563fa20e17d07241b9d736d7aaadc9ab5e4..e77657714ea980bf6c4ff537e63d23703c633a27 100644 (file)
@@ -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;