helly Tue May 9 23:53:40 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pcre php_pcre.c php_pcre.h Log: - MFH pcre_get_compiled_regex_cache() support http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/php_pcre.c?r1=1.168.2.9.2.1&r2=1.168.2.9.2.2&diff_format=u Index: php-src/ext/pcre/php_pcre.c diff -u php-src/ext/pcre/php_pcre.c:1.168.2.9.2.1 php-src/ext/pcre/php_pcre.c:1.168.2.9.2.2 --- php-src/ext/pcre/php_pcre.c:1.168.2.9.2.1 Tue May 9 18:29:26 2006 +++ php-src/ext/pcre/php_pcre.c Tue May 9 23:53:40 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.c,v 1.168.2.9.2.1 2006/05/09 18:29:26 andrei Exp $ */ +/* $Id: php_pcre.c,v 1.168.2.9.2.2 2006/05/09 23:53:40 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -180,18 +180,9 @@ } /* }}} */ -/* {{{ pcre_get_compiled_regex - */ -PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_options TSRMLS_DC) -{ - int compile_options; - return pcre_get_compiled_regex_ex(regex, extra, preg_options, &compile_options TSRMLS_CC); -} -/* }}} */ - -/* {{{ pcre_get_compiled_regex_ex +/* {{{ pcre_get_compiled_regex_cache */ -PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *compile_options TSRMLS_DC) +PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len, pcre_extra **extra, int *preg_options, int *compile_options TSRMLS_DC) { pcre *re = NULL; int coptions = 0; @@ -203,7 +194,6 @@ char end_delimiter; char *p, *pp; char *pattern; - int regex_len; int do_study = 0; int poptions = 0; unsigned const char *tables = NULL; @@ -230,7 +220,7 @@ *extra = pce->extra; *preg_options = pce->preg_options; *compile_options = pce->compile_options; - return pce->re; + return pce; #if HAVE_SETLOCALE } } @@ -393,9 +383,30 @@ new_entry.tables = tables; #endif zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry, - sizeof(pcre_cache_entry), NULL); + sizeof(pcre_cache_entry), (void**)&pce); - return re; + return pce; +} +/* }}} */ + +/* {{{ pcre_get_compiled_regex + */ +PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_options TSRMLS_DC) +{ + int compile_options; + pcre_cache_entry * pce = pcre_get_compiled_regex_cache(regex, strlen(regex), extra, preg_options, &compile_options TSRMLS_CC); + + return pce ? pce->re : NULL; +} +/* }}} */ + +/* {{{ pcre_get_compiled_regex_ex + */ +PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *compile_options TSRMLS_DC) +{ + pcre_cache_entry * pce = pcre_get_compiled_regex_cache(regex, strlen(regex), extra, preg_options, compile_options TSRMLS_CC); + + return pce ? pce->re : NULL; } /* }}} */ http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/php_pcre.h?r1=1.41.2.1.2.1&r2=1.41.2.1.2.2&diff_format=u Index: php-src/ext/pcre/php_pcre.h diff -u php-src/ext/pcre/php_pcre.h:1.41.2.1.2.1 php-src/ext/pcre/php_pcre.h:1.41.2.1.2.2 --- php-src/ext/pcre/php_pcre.h:1.41.2.1.2.1 Tue May 9 18:29:26 2006 +++ php-src/ext/pcre/php_pcre.h Tue May 9 23:53:40 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.h,v 1.41.2.1.2.1 2006/05/09 18:29:26 andrei Exp $ */ +/* $Id: php_pcre.h,v 1.41.2.1.2.2 2006/05/09 23:53:40 helly Exp $ */ #ifndef PHP_PCRE_H #define PHP_PCRE_H @@ -57,8 +57,11 @@ unsigned const char *tables; #endif int compile_options; + int refcount; } pcre_cache_entry; +PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len, pcre_extra **extra, int *preg_options, int *compile_options TSRMLS_DC); + ZEND_BEGIN_MODULE_GLOBALS(pcre) HashTable pcre_cache; long backtrack_limit;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php