]> granicus.if.org Git - php/commitdiff
Use HAVE_REGEX_T_RE_MAGIC to fix compilation problem on systems where
authorAndrei Zmievski <andrei@php.net>
Mon, 18 Jul 2005 17:34:38 +0000 (17:34 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 18 Jul 2005 17:34:38 +0000 (17:34 +0000)
re_magic is not provided publicly.

ext/ereg/ereg.c
ext/standard/reg.c

index ed073245999fa17f35375f1d04597ad6caf1ea44..0d5273a96a5a1c803df0387b84c7ca39f6878042 100644 (file)
@@ -46,6 +46,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
        
        if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
           && rc->cflags == cflags) {
+#ifdef HAVE_REGEX_T_RE_MAGIC
                /*
                 * 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.
@@ -73,7 +74,20 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
                zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
                                                 (void *) &rcp, sizeof(rcp), NULL);
        }
-       
+#else
+               memcpy(preg, &rc->preg, sizeof(*preg));
+       } else {
+               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);
+               }
+       }
+#endif
        return r;
 }
 /* }}} */
index ed073245999fa17f35375f1d04597ad6caf1ea44..0d5273a96a5a1c803df0387b84c7ca39f6878042 100644 (file)
@@ -46,6 +46,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
        
        if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
           && rc->cflags == cflags) {
+#ifdef HAVE_REGEX_T_RE_MAGIC
                /*
                 * 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.
@@ -73,7 +74,20 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
                zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
                                                 (void *) &rcp, sizeof(rcp), NULL);
        }
-       
+#else
+               memcpy(preg, &rc->preg, sizeof(*preg));
+       } else {
+               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);
+               }
+       }
+#endif
        return r;
 }
 /* }}} */