Browse Source

Correct option caching

experimental/newoperator
Andrey Hristov 27 years ago
parent
commit
7aa981f5b7
  1. 7
      ext/pcre/pcre.c
  2. 1
      ext/pcre/php_pcre.h

7
ext/pcre/pcre.c

@ -169,6 +169,7 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_
char *pattern; char *pattern;
int regex_len; int regex_len;
int do_study = 0; int do_study = 0;
int poptions = 0;
pcre_cache_entry *pce; pcre_cache_entry *pce;
pcre_cache_entry new_entry; pcre_cache_entry new_entry;
PCRE_LS_FETCH(); PCRE_LS_FETCH();
@ -178,6 +179,7 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_
regex_len = strlen(regex); regex_len = strlen(regex);
if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) { if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
extra = pce->extra; extra = pce->extra;
*preg_options = pce->preg_options;
return pce->re; return pce->re;
} }
@ -240,7 +242,7 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_
case 'X': coptions |= PCRE_EXTRA; break; case 'X': coptions |= PCRE_EXTRA; break;
/* Custom preg options */ /* Custom preg options */
case 'e': *preg_options |= PREG_REPLACE_EVAL; break;
case 'e': poptions |= PREG_REPLACE_EVAL; break;
case ' ': case ' ':
case '\n': case '\n':
@ -275,11 +277,14 @@ static pcre* _pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_
} }
} }
*preg_options = poptions;
efree(pattern); efree(pattern);
/* Store the compiled pattern and extra info in the cache. */ /* Store the compiled pattern and extra info in the cache. */
new_entry.re = re; new_entry.re = re;
new_entry.extra = extra; new_entry.extra = extra;
new_entry.preg_options = poptions;
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), NULL);

1
ext/pcre/php_pcre.h

@ -54,6 +54,7 @@ extern zend_module_entry pcre_module_entry;
typedef struct { typedef struct {
pcre *re; pcre *re;
pcre_extra *extra; pcre_extra *extra;
int preg_options;
} pcre_cache_entry; } pcre_cache_entry;
typedef struct { typedef struct {

Loading…
Cancel
Save