Skip to content

Commit db138c5

Browse files
author
foobar
committed
MFB4_4: Fix compile problem with --regex=system on some systems
1 parent 936e199 commit db138c5

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

ext/ereg/ereg.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
4646

4747
if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
4848
&& rc->cflags == cflags) {
49+
#ifdef HAVE_REGEX_T_RE_MAGIC
4950
/*
5051
* We use a saved magic number to see whether cache is corrupted, and if it
5152
* 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)
7374
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
7475
(void *) &rcp, sizeof(rcp), NULL);
7576
}
76-
77+
#else
78+
memcpy(preg, &rc->preg, sizeof(*preg));
79+
} else {
80+
r = regcomp(preg, pattern, cflags);
81+
if(!r) {
82+
reg_cache rcp;
83+
84+
rcp.cflags = cflags;
85+
memcpy(&rcp.preg, preg, sizeof(*preg));
86+
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
87+
(void *) &rcp, sizeof(rcp), NULL);
88+
}
89+
}
90+
#endif
7791
return r;
7892
}
7993
/* }}} */

ext/standard/reg.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
4646

4747
if(zend_hash_find(&REG(ht_rc), (char *) pattern, patlen+1, (void **) &rc) == SUCCESS
4848
&& rc->cflags == cflags) {
49+
#ifdef HAVE_REGEX_T_RE_MAGIC
4950
/*
5051
* We use a saved magic number to see whether cache is corrupted, and if it
5152
* 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)
7374
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
7475
(void *) &rcp, sizeof(rcp), NULL);
7576
}
76-
77+
#else
78+
memcpy(preg, &rc->preg, sizeof(*preg));
79+
} else {
80+
r = regcomp(preg, pattern, cflags);
81+
if(!r) {
82+
reg_cache rcp;
83+
84+
rcp.cflags = cflags;
85+
memcpy(&rcp.preg, preg, sizeof(*preg));
86+
zend_hash_update(&REG(ht_rc), (char *) pattern, patlen+1,
87+
(void *) &rcp, sizeof(rcp), NULL);
88+
}
89+
}
90+
#endif
7791
return r;
7892
}
7993
/* }}} */

0 commit comments

Comments
 (0)