1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 18:22:42 +01:00

Merge branch 'PHP-5.6' into PHP-7.0

* PHP-5.6:
  Implement #47456: Missing PCRE option 'J'
This commit is contained in:
Stanislav Malyshev
2016-09-05 00:38:57 -07:00
2 changed files with 102 additions and 0 deletions

View File

@@ -431,6 +431,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
coptions |= PCRE_UCP;
#endif
break;
case 'J': coptions |= PCRE_DUPNAMES; break;
/* Custom preg options */
case 'e': poptions |= PREG_REPLACE_EVAL; break;

View File

@@ -0,0 +1,101 @@
--TEST--
Request #47456 (Missing PCRE option 'J')
--DESCRIPTION--
The J modifier is supposed to be identical to the internal option (?J), so we're
testing both.
--FILE--
<?php
preg_match_all('/(?J)(?<chr>[ac])(?<num>\d)|(?<chr>[b])/', 'a1bc3', $m, PREG_SET_ORDER);
var_dump($m);
unset($m);
preg_match_all('/(?<chr>[ac])(?<num>\d)|(?<chr>[b])/J', 'a1bc3', $m, PREG_SET_ORDER);
var_dump($m);
?>
--EXPECT--
array(3) {
[0]=>
array(5) {
[0]=>
string(2) "a1"
["chr"]=>
string(1) "a"
[1]=>
string(1) "a"
["num"]=>
string(1) "1"
[2]=>
string(1) "1"
}
[1]=>
array(6) {
[0]=>
string(1) "b"
["chr"]=>
string(1) "b"
[1]=>
string(0) ""
["num"]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
string(1) "b"
}
[2]=>
array(5) {
[0]=>
string(2) "c3"
["chr"]=>
string(1) "c"
[1]=>
string(1) "c"
["num"]=>
string(1) "3"
[2]=>
string(1) "3"
}
}
array(3) {
[0]=>
array(5) {
[0]=>
string(2) "a1"
["chr"]=>
string(1) "a"
[1]=>
string(1) "a"
["num"]=>
string(1) "1"
[2]=>
string(1) "1"
}
[1]=>
array(6) {
[0]=>
string(1) "b"
["chr"]=>
string(1) "b"
[1]=>
string(0) ""
["num"]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
string(1) "b"
}
[2]=>
array(5) {
[0]=>
string(2) "c3"
["chr"]=>
string(1) "c"
[1]=>
string(1) "c"
["num"]=>
string(1) "3"
[2]=>
string(1) "3"
}
}