helly           Wed Oct 12 18:37:34 2005 EDT

  Modified files:              
    /php-src/ext/pcre   php_pcre.c php_pcre.h 
  Log:
  - Add/expose function to compile and access pcre_cache_entry structs
  
http://cvs.php.net/diff.php/php-src/ext/pcre/php_pcre.c?r1=1.171&r2=1.172&ty=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.171 php-src/ext/pcre/php_pcre.c:1.172
--- php-src/ext/pcre/php_pcre.c:1.171   Tue Oct 11 02:46:15 2005
+++ php-src/ext/pcre/php_pcre.c Wed Oct 12 18:37:29 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.171 2005/10/11 06:46:15 dmitry Exp $ */
+/* $Id: php_pcre.c,v 1.172 2005/10/12 22:37:29 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -124,18 +124,9 @@
 }
 /* }}} */
 
-/* {{{ pcre_get_compiled_regex
+/* {{{ pcre_get_compiled_regex_cache_ex
  */
-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
- */
-PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int 
*preg_options, int *compile_options TSRMLS_DC)
+static pcre_cache_entry* pcre_get_compiled_regex_cache_ex(char *regex, int 
regex_len, pcre_extra **extra, int *preg_options, int *compile_options 
TSRMLS_DC)
 {
        pcre                            *re = NULL;
        int                                      coptions = 0;
@@ -147,7 +138,6 @@
        char                             end_delimiter;
        char                            *p, *pp;
        char                            *pattern;
-       int                                      regex_len;
        int                                      do_study = 0;
        int                                      poptions = 0;
        unsigned const char *tables = NULL;
@@ -174,7 +164,7 @@
                                *extra = pce->extra;
                                *preg_options = pce->preg_options;
                                *compile_options = pce->compile_options;
-                               return pce->re;
+                               return pce;
 #if HAVE_SETLOCALE
                        }
                }
@@ -334,9 +324,41 @@
        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 pce;
+}
+/* }}} */
 
-       return re;
+/* {{{ 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_ex(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_ex(regex, 
strlen(regex), extra, preg_options, compile_options TSRMLS_CC);
+       
+       return pce ? pce->re : NULL;
+}
+/* }}} */
+
+/* {{{ pcre_get_compiled_regex_cache
+ */
+PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int 
regex_len TSRMLS_DC)
+{
+       pcre_extra *extra;
+       int preg_options;
+       int compile_options;
+       return pcre_get_compiled_regex_cache_ex(regex, regex_len, &extra, 
&preg_options, &compile_options TSRMLS_CC);
 }
 /* }}} */
 
http://cvs.php.net/diff.php/php-src/ext/pcre/php_pcre.h?r1=1.41&r2=1.42&ty=u
Index: php-src/ext/pcre/php_pcre.h
diff -u php-src/ext/pcre/php_pcre.h:1.41 php-src/ext/pcre/php_pcre.h:1.42
--- php-src/ext/pcre/php_pcre.h:1.41    Wed Aug  3 10:07:38 2005
+++ php-src/ext/pcre/php_pcre.h Wed Oct 12 18:37:30 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: php_pcre.h,v 1.41 2005/08/03 14:07:38 sniper Exp $ */
+/* $Id: php_pcre.h,v 1.42 2005/10/12 22:37:30 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 TSRMLS_DC);
+
 ZEND_BEGIN_MODULE_GLOBALS(pcre)
        HashTable pcre_cache;
 ZEND_END_MODULE_GLOBALS(pcre)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to