iliaa Thu Jan 8 00:41:34 2009 UTC
Modified files:
/php-src/ext/ereg ereg.c
Log:
MFB: Simplify parameter parsing
http://cvs.php.net/viewvc.cgi/php-src/ext/ereg/ereg.c?r1=1.97&r2=1.98&diff_format=u
Index: php-src/ext/ereg/ereg.c
diff -u php-src/ext/ereg/ereg.c:1.97 php-src/ext/ereg/ereg.c:1.98
--- php-src/ext/ereg/ereg.c:1.97 Wed Dec 31 11:12:30 2008
+++ php-src/ext/ereg/ereg.c Thu Jan 8 00:41:33 2009
@@ -17,7 +17,7 @@
| Jaakko Hyvätti <[email protected]> |
+----------------------------------------------------------------------+
*/
-/* $Id: ereg.c,v 1.97 2008/12/31 11:12:30 sebastian Exp $ */
+/* $Id: ereg.c,v 1.98 2009/01/08 00:41:33 iliaa Exp $ */
#include <stdio.h>
#include <ctype.h>
@@ -593,33 +593,25 @@
*/
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;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php