[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Wed Apr 2 19:01:44 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fixed lots of crashes in mbregex. # most of them were caused by stupid mistakes Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.36 php4/ext/mbstring/php_mbregex.c:1.37 --- php4/ext/mbstring/php_mbregex.c:1.36Tue Apr 1 13:56:59 2003 +++ php4/ext/mbstring/php_mbregex.c Wed Apr 2 19:01:44 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.36 2003/04/01 18:56:59 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.37 2003/04/03 00:01:44 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -405,6 +405,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase) { + zval tmp; zval *arg_pattern, *array; char *string; int string_len; @@ -427,10 +428,13 @@ /* compile the regular expression from the supplied regex */ if (Z_TYPE_P(arg_pattern) != IS_STRING) { /* we convert numbers to integers and treat them as a string */ - if (Z_TYPE_P(arg_pattern) == IS_DOUBLE) { - convert_to_long_ex(arg_pattern); /* get rid of decimal places */ + tmp = *arg_pattern; + zval_copy_ctor(tmp); + if (Z_TYPE_P(tmp) == IS_DOUBLE) { + convert_to_long(tmp); /* get rid of decimal places */ } - convert_to_string_ex(arg_pattern); + convert_to_string(tmp); + arg_pattern = tmp; /* don't bother doing an extended regex with just a number */ } err = php_mbregex_compile_pattern( @@ -439,7 +443,8 @@ Z_STRLEN_P(arg_pattern), option, MBSTRG(current_mbctype) TSRMLS_CC); if (err) { - RETURN_FALSE; + RETVAL_FALSE; + goto out; } /* actually execute the regular expression */ @@ -451,7 +456,8 @@ regs); if (err 0) { mbre_free_registers(regs); - RETURN_FALSE; + RETVAL_FALSE; + goto out; } match_len = 1; @@ -476,6 +482,10 @@ match_len = 1; } RETVAL_LONG(match_len); +out: + if (arg_pattern == tmp) { + zval_dtor(tmp); + } } /* {{{ proto int mb_ereg(string pattern, string string [, array registers]) @@ -690,25 +700,29 @@ split multibyte string into array by regular expression */ PHP_FUNCTION(mb_split) { - zval *arg_pat; + char *arg_pattern; + int arg_pattern_len; mb_regex_t re; struct mbre_registers regs = {0, 0, 0, 0}; char *string; - int n, err, string_len, pos; + int string_len; + + int n, err, pos; long count = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, zs|l, arg_pat, - string, string_len, count) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|l, arg_pattern, arg_pattern_len, string, string_len, count) == FAILURE) { RETURN_FALSE; } - if (count == 0) count = 1; + if (count == 0) { + count = 1; + } /* create regex pattern buffer */ err = php_mbregex_compile_pattern( re, -Z_STRVAL_P(arg_pat), -Z_STRLEN_P(arg_pat), +arg_pattern, +arg_pattern_len, MBSTRG(regex_default_options), MBSTRG(current_mbctype) TSRMLS_CC); if (err) { RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Wed Apr 2 19:15:13 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fixed segfault in mb_ereg_match() Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.37 php4/ext/mbstring/php_mbregex.c:1.38 --- php4/ext/mbstring/php_mbregex.c:1.37Wed Apr 2 19:01:44 2003 +++ php4/ext/mbstring/php_mbregex.c Wed Apr 2 19:15:13 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.37 2003/04/03 00:01:44 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.38 2003/04/03 00:15:13 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -782,7 +782,8 @@ Regular expression match for multibyte string */ PHP_FUNCTION(mb_ereg_match) { - zval *arg_pattern; + char *arg_pattern; + int arg_pattern_len; char *string; int string_len; @@ -795,8 +796,8 @@ char *option_str = NULL; int option_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, zs|s, - arg_pattern, string, string_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|s, + arg_pattern, arg_pattern_len, string, string_len, option_str, option_str_len)==FAILURE) { RETURN_FALSE; } @@ -807,12 +808,11 @@ option |= MBSTRG(regex_default_options); } } - convert_to_string_ex(arg_pattern); err = php_mbregex_compile_pattern( re, - Z_STRVAL_P(arg_pattern), - Z_STRLEN_P(arg_pattern), + arg_pattern, + arg_pattern_len, option, MBSTRG(current_mbctype) TSRMLS_CC); if (err) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Tue Apr 1 13:44:00 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fixed crash that occurs due to an abused persistent hashtable. # thanks Sascha again. Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.33 php4/ext/mbstring/php_mbregex.c:1.34 --- php4/ext/mbstring/php_mbregex.c:1.33Tue Mar 4 12:10:29 2003 +++ php4/ext/mbstring/php_mbregex.c Tue Apr 1 13:44:00 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.33 2003/03/04 17:10:29 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.34 2003/04/01 18:44:00 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -96,7 +96,6 @@ { MBSTRG(default_mbctype) = MBCTYPE_EUC; MBSTRG(current_mbctype) = MBCTYPE_EUC; - zend_hash_init((MBSTRG(ht_rc)), 0, NULL, (void (*)(void *)) php_mb_regex_free_cache, 1); MBSTRG(search_str) = (zval**)0; MBSTRG(search_str_val) = (zval*)0; MBSTRG(search_re) = (mb_regex_t*)0; @@ -108,7 +107,6 @@ /* {{{ _php_mb_regex_globals_dtor */ void _php_mb_regex_globals_dtor(zend_mbstring_globals *pglobals TSRMLS_DC) { - zend_hash_destroy(MBSTRG(ht_rc)); } /* }}} */ @@ -138,6 +136,7 @@ PHP_RINIT_FUNCTION(mb_regex) { MBSTRG(regex_default_options) = MBRE_OPTION_POSIXLINE; + zend_hash_init((MBSTRG(ht_rc)), 0, NULL, (void (*)(void *)) php_mb_regex_free_cache, 0); return SUCCESS; } @@ -167,7 +166,7 @@ efree(MBSTRG(search_regs)); MBSTRG(search_regs) = (struct mbre_registers*)0; } - zend_hash_clean(MBSTRG(ht_rc)); + zend_hash_destroy(MBSTRG(ht_rc)); return SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Tue Apr 1 13:56:26 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Reverted the last patch; the problem is elsewhere.. Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.34 php4/ext/mbstring/php_mbregex.c:1.35 --- php4/ext/mbstring/php_mbregex.c:1.34Tue Apr 1 13:44:00 2003 +++ php4/ext/mbstring/php_mbregex.c Tue Apr 1 13:56:26 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.34 2003/04/01 18:44:00 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.35 2003/04/01 18:56:26 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -96,6 +96,7 @@ { MBSTRG(default_mbctype) = MBCTYPE_EUC; MBSTRG(current_mbctype) = MBCTYPE_EUC; + zend_hash_init((MBSTRG(ht_rc)), 0, NULL, (void (*)(void *)) php_mb_regex_free_cache, 1); MBSTRG(search_str) = (zval**)0; MBSTRG(search_str_val) = (zval*)0; MBSTRG(search_re) = (mb_regex_t*)0; @@ -107,6 +108,7 @@ /* {{{ _php_mb_regex_globals_dtor */ void _php_mb_regex_globals_dtor(zend_mbstring_globals *pglobals TSRMLS_DC) { + zend_hash_destroy(MBSTRG(ht_rc)); } /* }}} */ @@ -136,7 +138,6 @@ PHP_RINIT_FUNCTION(mb_regex) { MBSTRG(regex_default_options) = MBRE_OPTION_POSIXLINE; - zend_hash_init((MBSTRG(ht_rc)), 0, NULL, (void (*)(void *)) php_mb_regex_free_cache, 0); return SUCCESS; } @@ -166,7 +167,7 @@ efree(MBSTRG(search_regs)); MBSTRG(search_regs) = (struct mbre_registers*)0; } - zend_hash_destroy(MBSTRG(ht_rc)); + zend_hash_clean(MBSTRG(ht_rc)); return SUCCESS; } @@ -233,7 +234,7 @@ const char *err_str = NULL; mb_regex_t *rc = NULL; - if(zend_hash_find(MBSTRG(ht_rc), (char *)pattern, patlen+1, (void **) rc) == FAILURE || + if(1 || zend_hash_find(MBSTRG(ht_rc), (char *)pattern, patlen+1, (void **) rc) == FAILURE || rc-options != options || rc-mbctype != mbctype) { memset(pre, 0, sizeof(*pre)); pre-fastmap = (char*)emalloc((1 MBRE_BYTEWIDTH)*sizeof(char)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Tue Apr 1 13:56:59 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: oops Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.35 php4/ext/mbstring/php_mbregex.c:1.36 --- php4/ext/mbstring/php_mbregex.c:1.35Tue Apr 1 13:56:26 2003 +++ php4/ext/mbstring/php_mbregex.c Tue Apr 1 13:56:59 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.35 2003/04/01 18:56:26 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.36 2003/04/01 18:56:59 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -234,7 +234,7 @@ const char *err_str = NULL; mb_regex_t *rc = NULL; - if(1 || zend_hash_find(MBSTRG(ht_rc), (char *)pattern, patlen+1, (void **) rc) == FAILURE || + if(zend_hash_find(MBSTRG(ht_rc), (char *)pattern, patlen+1, (void **) rc) == FAILURE || rc-options != options || rc-mbctype != mbctype) { memset(pre, 0, sizeof(*pre)); pre-fastmap = (char*)emalloc((1 MBRE_BYTEWIDTH)*sizeof(char)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Thu Jan 23 15:38:44 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Really fixed the mb issue of mb_ereg_replace() # my previous patch is somewhat wrong Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.31 php4/ext/mbstring/php_mbregex.c:1.32 --- php4/ext/mbstring/php_mbregex.c:1.31Thu Jan 23 15:07:39 2003 +++ php4/ext/mbstring/php_mbregex.c Thu Jan 23 15:38:44 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.31 2003/01/23 20:07:39 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.32 2003/01/23 20:38:44 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -619,7 +619,7 @@ p += 2; i += 2; } else { - _php_mb_regex_strbuf_ncat(pdevice, (const unsigned char *)p, 1); + _php_mb_regex_strbuf_ncat(pdevice, (const +unsigned char *)p, fwd); p += fwd; i += fwd; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Tue Jan 21 14:31:08 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fixed mb_ereg_search() segfault that occurs when the function is called before a string to be searched is passed by mb_ereg_search_init() Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.27 php4/ext/mbstring/php_mbregex.c:1.28 --- php4/ext/mbstring/php_mbregex.c:1.27Sat Jan 18 15:09:29 2003 +++ php4/ext/mbstring/php_mbregex.c Tue Jan 21 14:31:07 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.27 2003/01/18 20:09:29 iliaa Exp $ */ +/* $Id: php_mbregex.c,v 1.28 2003/01/21 19:31:07 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -855,7 +855,7 @@ pos = MBSTRG(search_pos); str = NULL; len = 0; - if (Z_TYPE_PP(MBSTRG(search_str)) == IS_STRING){ + if (MBSTRG(search_str) != NULL Z_TYPE_PP(MBSTRG(search_str)) == IS_STRING){ str = (unsigned char *)Z_STRVAL_PP(MBSTRG(search_str)); len = Z_STRLEN_PP(MBSTRG(search_str)); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Tue Jan 21 17:03:30 2003 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fixed mb_ereg_replace() bug (the function has ignored the default option) Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.28 php4/ext/mbstring/php_mbregex.c:1.29 --- php4/ext/mbstring/php_mbregex.c:1.28Tue Jan 21 14:31:07 2003 +++ php4/ext/mbstring/php_mbregex.c Tue Jan 21 17:03:29 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_mbregex.c,v 1.28 2003/01/21 19:31:07 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.29 2003/01/21 22:03:29 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H @@ -661,7 +661,7 @@ Replace regular expression for multibyte string */ PHP_FUNCTION(mb_ereg_replace) { - _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAM_PASSTHRU, +MBSTRG(regex_default_options)); } /* }}} */ @@ -669,7 +669,7 @@ Case insensitive replace regular expression for multibyte string */ PHP_FUNCTION(mb_eregi_replace) { - _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAM_PASSTHRU, MBRE_OPTION_IGNORECASE); + _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAM_PASSTHRU, +MBRE_OPTION_IGNORECASE | MBSTRG(regex_default_options)); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Thu Nov 14 14:04:30 2002 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fix build Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.20 php4/ext/mbstring/php_mbregex.c:1.21 --- php4/ext/mbstring/php_mbregex.c:1.20Thu Nov 14 13:54:42 2002 +++ php4/ext/mbstring/php_mbregex.c Thu Nov 14 14:04:29 2002 -16,7 +16,7 +--+ */ -/* $Id: php_mbregex.c,v 1.20 2002/11/14 18:54:42 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.21 2002/11/14 19:04:29 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H -34,7 +34,7 ZEND_EXTERN_MODULE_GLOBALS(mbstring) #ifdef ZTS -static MUTEX_T mbregex_locale_mutex = NULL; +MUTEX_T mbregex_locale_mutex = NULL; #endif /* -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Sun Oct 20 11:11:05 2002 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Changed mb_regex_set_options() more informative Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.15 php4/ext/mbstring/php_mbregex.c:1.16 --- php4/ext/mbstring/php_mbregex.c:1.15Thu Oct 10 13:00:36 2002 +++ php4/ext/mbstring/php_mbregex.c Sun Oct 20 11:11:04 2002 -16,7 +16,7 +--+ */ -/* $Id: php_mbregex.c,v 1.15 2002/10/10 17:00:36 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.16 2002/10/20 15:11:04 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H -169,6 +169,73 return res; } +static size_t +_php_mb_regex_get_option_string(char *str, size_t len, int option) +{ + size_t len_left = len; + size_t len_req = 0; + char *p = str; + + + if ((option MBRE_OPTION_IGNORECASE) != 0) { + if (len_left 0) { + --len_left; + *(p++) = 'i'; + } + ++len_req; + } + + if ((option MBRE_OPTION_EXTENDED) != 0) { + if (len_left 0) { + --len_left; + *(p++) = 'x'; + } + ++len_req; + } + + if ((option MBRE_OPTION_POSIXLINE) == MBRE_OPTION_POSIXLINE) { + if (len_left 0) { + --len_left; + *(p++) = 'p'; + } + ++len_req; + } else { + if ((option MBRE_OPTION_MULTILINE) != 0) { + if (len_left 0) { + --len_left; + *(p++) = 'm'; + } + ++len_req; + } + + if ((option MBRE_OPTION_SINGLELINE) != 0) { + if (len_left 0) { + --len_left; + *(p++) = 's'; + } + ++len_req; + } + } + if ((option MBRE_OPTION_LONGEST) != 0) { + if (len_left 0) { + --len_left; + *(p++) = 'l'; + } + ++len_req; + } + if (len_left 0) { + --len_left; + *(p++) = '\0'; + } + + ++len_req; + if (len len_req) { + return len_req; + } + + return 0; +} + static void _php_mb_regex_init_options(const char *parg, int narg, int *option, int *eval) { -974,18 +1041,28 } /* }}} */ -/* {{{ proto bool mb_regex_set_options([string options]) - Set the default options for mbregex functions */ +/* {{{ proto string mb_regex_set_options([string options]) + Set or get the default options for mbregex functions */ PHP_FUNCTION(mb_regex_set_options) { - char *string; + int opt; + char *string = NULL; int string_len; - if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, s, + char buf[16]; + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, |s, string, string_len ) == FAILURE ) { RETURN_FALSE; } - php_mb_regex_set_options_by_string( (const char*)string, string_len TSRMLS_CC); - RETURN_TRUE; + if (string != NULL) { + opt = php_mb_regex_set_options_by_string( (const char*)string, + string_len TSRMLS_CC ); + } else { + opt = MBSTRG(regex_default_options); + } + _php_mb_regex_get_option_string(buf, sizeof(buf), opt); + + RETVAL_STRING(buf, 1); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Mon Oct 7 16:12:48 2002 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: Fixed typo. Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.12 php4/ext/mbstring/php_mbregex.c:1.13 --- php4/ext/mbstring/php_mbregex.c:1.12Mon Oct 7 13:59:48 2002 +++ php4/ext/mbstring/php_mbregex.c Mon Oct 7 16:12:48 2002 -16,7 +16,7 +--+ */ -/* $Id: php_mbregex.c,v 1.12 2002/10/07 17:59:48 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.13 2002/10/07 20:12:48 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H -974,7 +974,7 } /* }}} */ -/* {{{ proto bool mb_regex_set_options([string encoding]) +/* {{{ proto bool mb_regex_set_options([string options]) Set the default options for mbregex functions */ PHP_FUNCTION(mb_regex_set_options) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c php_mbregex.h
sebastian Tue Oct 8 01:08:39 2002 EDT Modified files: /php4/ext/mbstring php_mbregex.c php_mbregex.h Log: Fix ZTS build. Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.13 php4/ext/mbstring/php_mbregex.c:1.14 --- php4/ext/mbstring/php_mbregex.c:1.13Mon Oct 7 16:12:48 2002 +++ php4/ext/mbstring/php_mbregex.c Tue Oct 8 01:08:39 2002 -16,7 +16,7 +--+ */ -/* $Id: php_mbregex.c,v 1.13 2002/10/07 20:12:48 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.14 2002/10/08 05:08:39 sebastian Exp $ */ #ifdef HAVE_CONFIG_H -529,7 +529,7 count = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), zs|l, arg_pat, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, zs|l, arg_pat, string, string_len, count) == FAILURE) { RETURN_FALSE; } -957,7 +957,7 /* }}} */ /* {{{ php_mb_regex_set_options */ -PHPAPI int php_mb_regex_set_options( int options ) +PHPAPI int php_mb_regex_set_options( int options TSRMLS_DC) { int prev_opt = MBSTRG(regex_default_options); MBSTRG(regex_default_options) = options; -966,11 +966,11 /* }}} */ /* {{{ php_mb_regex_set_options_by_string */ -PHPAPI int php_mb_regex_set_options_by_string( const char *opt_str, int len ) +PHPAPI int php_mb_regex_set_options_by_string( const char *opt_str, int len TSRMLS_DC) { int new_opt; _php_mb_regex_init_options( opt_str, len, new_opt, NULL); - return php_mb_regex_set_options( new_opt ); + return php_mb_regex_set_options( new_opt TSRMLS_CC); } /* }}} */ -984,7 +984,7 string, string_len ) == FAILURE ) { RETURN_FALSE; } - php_mb_regex_set_options_by_string( (const char*)string, string_len ); + php_mb_regex_set_options_by_string( (const char*)string, string_len TSRMLS_CC); RETURN_TRUE; } /* }}} */ Index: php4/ext/mbstring/php_mbregex.h diff -u php4/ext/mbstring/php_mbregex.h:1.1 php4/ext/mbstring/php_mbregex.h:1.2 --- php4/ext/mbstring/php_mbregex.h:1.1 Mon Oct 7 13:59:49 2002 +++ php4/ext/mbstring/php_mbregex.h Tue Oct 8 01:08:39 2002 -16,7 +16,7 +--+ */ -/* $Id: php_mbregex.h,v 1.1 2002/10/07 17:59:49 moriyoshi Exp $ */ +/* $Id: php_mbregex.h,v 1.2 2002/10/08 05:08:39 sebastian Exp $ */ #ifndef _PHP_MBREGEX_H #define _PHP_MBREGEX_H -43,8 +43,8 #define PHP_MBREGEX_MAXCACHE 50 PHPAPI int php_mb_regex_name2mbctype(const char *pname); -PHPAPI int php_mb_regex_set_options(int options); -PHPAPI int php_mb_regex_set_options_by_string(const char *optstr, int len); +PHPAPI int php_mb_regex_set_options(int options TSRMLS_DC); +PHPAPI int php_mb_regex_set_options_by_string(const char *optstr, int len TSRMLS_DC); PHP_FUNCTION(mb_regex_encoding); PHP_FUNCTION(mb_ereg); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mbstring php_mbregex.c
moriyoshi Sun Oct 6 02:37:48 2002 EDT Modified files: /php4/ext/mbstring php_mbregex.c Log: made messages more consistent Index: php4/ext/mbstring/php_mbregex.c diff -u php4/ext/mbstring/php_mbregex.c:1.6 php4/ext/mbstring/php_mbregex.c:1.7 --- php4/ext/mbstring/php_mbregex.c:1.6 Sun Oct 6 02:21:34 2002 +++ php4/ext/mbstring/php_mbregex.c Sun Oct 6 02:37:47 2002 -16,7 +16,7 +--+ */ -/* $Id: php_mbregex.c,v 1.6 2002/10/06 06:21:34 moriyoshi Exp $ */ +/* $Id: php_mbregex.c,v 1.7 2002/10/06 06:37:47 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H -229,7 +229,7 convert_to_string_ex(arg1); mbctype = php_mbregex_name2mbctype(Z_STRVAL_PP(arg1)); if (mbctype 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, unknown encoding \%s\, Z_STRVAL_PP(arg1)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown encoding +\%s\, Z_STRVAL_PP(arg1)); RETVAL_FALSE; } else { MBSTRG(current_mbctype) = mbctype; -726,11 +726,11 } if (!MBSTRG(search_re)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, no regex for search); + php_error_docref(NULL TSRMLS_CC, E_WARNING, No regex given); RETURN_FALSE; } if (!str) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, no string for search); + php_error_docref(NULL TSRMLS_CC, E_WARNING, No string given); RETURN_FALSE; } if (MBSTRG(search_regs)) { -962,8 +962,11 } convert_to_long_ex(arg_pos); n = Z_LVAL_PP(arg_pos); - if (n 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, position is minus value); + if (n 0 + || ( MBSTRG(search_str) != NULL *MBSTRG(search_str) != NULL +Z_TYPE_PP(MBSTRG(search_str)) == IS_STRING +n = Z_STRLEN_PP(MBSTRG(search_str)) ) ) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Position is out of +range); MBSTRG(search_pos) = 0; RETVAL_FALSE; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php