andrei Tue May 24 17:12:16 2005 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/pcre php_pcre.c
Log:
MFH (pcre cache flush)
http://cvs.php.net/diff.php/php-src/ext/pcre/php_pcre.c?r1=1.132.2.22&r2=1.132.2.23&ty=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.132.2.22
php-src/ext/pcre/php_pcre.c:1.132.2.23
--- php-src/ext/pcre/php_pcre.c:1.132.2.22 Fri Jan 21 05:34:46 2005
+++ php-src/ext/pcre/php_pcre.c Tue May 24 17:12:16 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.132.2.22 2005/01/21 10:34:46 derick Exp $ */
+/* $Id: php_pcre.c,v 1.132.2.23 2005/05/24 21:12:16 andrei Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -152,13 +152,21 @@
back the compiled pattern, otherwise go on and compile it. */
regex_len = strlen(regex);
if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void
**)&pce) == SUCCESS) {
+ /*
+ * We use a quick pcre_info() check to see whether cache is
corrupted, and if it
+ * is, we flush it and compile the pattern from scratch.
+ */
+ if (pcre_info(pce->re, NULL, NULL) == PCRE_ERROR_BADMAGIC) {
+ zend_hash_clean(&PCRE_G(pcre_cache));
+ } else {
#if HAVE_SETLOCALE
- if (!strcmp(pce->locale, locale)) {
+ if (!strcmp(pce->locale, locale)) {
#endif
- *extra = pce->extra;
- *preg_options = pce->preg_options;
- return pce->re;
+ *extra = pce->extra;
+ *preg_options = pce->preg_options;
+ return pce->re;
#if HAVE_SETLOCALE
+ }
}
#endif
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php