mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
- MFH pcre_get_compiled_regex_cache() support
This commit is contained in:
parent
637a40423c
commit
0de69fe97d
2 changed files with 29 additions and 15 deletions
|
@ -180,18 +180,9 @@ static int pcre_clean_cache(void *data, void *arg TSRMLS_DC)
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ pcre_get_compiled_regex
|
/* {{{ pcre_get_compiled_regex_cache
|
||||||
*/
|
*/
|
||||||
PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *preg_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)
|
||||||
{
|
|
||||||
int compile_options;
|
|
||||||
return pcre_get_compiled_regex_ex(regex, extra, preg_options, &compile_options TSRMLS_CC);
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ 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 *re = NULL;
|
pcre *re = NULL;
|
||||||
int coptions = 0;
|
int coptions = 0;
|
||||||
|
@ -203,7 +194,6 @@ PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *pr
|
||||||
char end_delimiter;
|
char end_delimiter;
|
||||||
char *p, *pp;
|
char *p, *pp;
|
||||||
char *pattern;
|
char *pattern;
|
||||||
int regex_len;
|
|
||||||
int do_study = 0;
|
int do_study = 0;
|
||||||
int poptions = 0;
|
int poptions = 0;
|
||||||
unsigned const char *tables = NULL;
|
unsigned const char *tables = NULL;
|
||||||
|
@ -230,7 +220,7 @@ PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *pr
|
||||||
*extra = pce->extra;
|
*extra = pce->extra;
|
||||||
*preg_options = pce->preg_options;
|
*preg_options = pce->preg_options;
|
||||||
*compile_options = pce->compile_options;
|
*compile_options = pce->compile_options;
|
||||||
return pce->re;
|
return pce;
|
||||||
#if HAVE_SETLOCALE
|
#if HAVE_SETLOCALE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,9 +383,30 @@ PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *pr
|
||||||
new_entry.tables = tables;
|
new_entry.tables = tables;
|
||||||
#endif
|
#endif
|
||||||
zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry,
|
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;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,11 @@ typedef struct {
|
||||||
unsigned const char *tables;
|
unsigned const char *tables;
|
||||||
#endif
|
#endif
|
||||||
int compile_options;
|
int compile_options;
|
||||||
|
int refcount;
|
||||||
} pcre_cache_entry;
|
} 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)
|
ZEND_BEGIN_MODULE_GLOBALS(pcre)
|
||||||
HashTable pcre_cache;
|
HashTable pcre_cache;
|
||||||
long backtrack_limit;
|
long backtrack_limit;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue