Hi Andrei,

./configure --with-regex=system doesn't work for me after this patch.

Thanks. Dmitry.

> -----Original Message-----
> From: Andrei Zmievski [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 27, 2005 1:50 AM
> To: php-cvs@lists.php.net
> Subject: [PHP-CVS] cvs: php-src(PHP_5_0) /ext/standard reg.c 
> 
> 
> andrei                Thu May 26 17:49:32 2005 EDT
> 
>   Modified files:              (Branch: PHP_5_0)
>     /php-src/ext/standard     reg.c 
>   Log:
>   MFH
>   
>   
> http://cvs.php.net/diff.php/php-src/ext/standard/reg.c?r1=1.78
> &r2=1.78.2.1&ty=u
> Index: php-src/ext/standard/reg.c
> diff -u php-src/ext/standard/reg.c:1.78 
> php-src/ext/standard/reg.c:1.78.2.1
> --- php-src/ext/standard/reg.c:1.78   Thu Jan  8 03:17:34 2004
> +++ php-src/ext/standard/reg.c        Thu May 26 17:49:32 2005
> @@ -17,7 +17,7 @@
>     |          Jaakko Hyvдtti <[EMAIL PROTECTED]>         
>              | 
>     
> +-------------------------------------------------------------
> ---------+
>   */
> -/* $Id: reg.c,v 1.78 2004/01/08 08:17:34 andi Exp $ */
> +/* $Id: reg.c,v 1.78.2.1 2005/05/26 21:49:32 andrei Exp $ */
>  
>  #include <stdio.h>
>  #include <ctype.h>
> @@ -33,6 +33,8 @@
>       int cflags;
>  } reg_cache;
>  
> +static int reg_magic = 0;
> +
>  /* {{{ _php_regcomp
>   */
>  static int _php_regcomp(regex_t *preg, const char *pattern, 
> int cflags) @@ -42,19 +44,34 @@
>       reg_cache *rc = NULL;
>       TSRMLS_FETCH();
>       
> -     if(zend_hash_find(&REG(ht_rc), (char *) pattern, 
> patlen+1, (void **) &rc) == FAILURE ||
> -                     rc->cflags != cflags) {
> -             r = regcomp(preg, pattern, cflags);
> -             if(!r) {
> -                     reg_cache rcp;
> -
> -                     rcp.cflags = cflags;
> -                     memcpy(&rcp.preg, preg, sizeof(*preg));
> -                     zend_hash_update(&REG(ht_rc), (char *) 
> pattern, patlen+1,
> -                                     (void *) &rcp, 
> sizeof(rcp), NULL);
> +     if(zend_hash_find(&REG(ht_rc), (char *) pattern, 
> patlen+1, (void **) &rc) == SUCCESS
> +        && rc->cflags == cflags) {
> +             /*
> +              * We use a saved magic number to see whether 
> cache is corrupted, and if it
> +              * is, we flush it and compile the pattern from scratch.
> +              */
> +             if (rc->preg.re_magic != reg_magic) {
> +                     zend_hash_clean(&REG(ht_rc));
> +             } else {
> +                     memcpy(preg, &rc->preg, sizeof(*preg));
> +                     return r;
>               }
> -     } else {
> -             memcpy(preg, &rc->preg, sizeof(*preg));
> +     }
> +
> +     r = regcomp(preg, pattern, cflags);
> +     if(!r) {
> +             reg_cache rcp;
> +
> +             rcp.cflags = cflags;
> +             memcpy(&rcp.preg, preg, sizeof(*preg));
> +             /*
> +              * Since we don't have access to the actual 
> MAGIC1 definition in the private
> +              * header file, we save the magic value 
> immediately after compilation. Hopefully,
> +              * it's good.
> +              */
> +             if (!reg_magic) reg_magic = preg->re_magic;
> +             zend_hash_update(&REG(ht_rc), (char *) pattern, 
> patlen+1,
> +                                              (void *) &rcp, 
> sizeof(rcp), NULL);
>       }
>       
>       return r;
> 
> -- 
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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

Reply via email to