summaryrefslogtreecommitdiff
path: root/ext/pcre/tests
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/pcre/tests
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/pcre/tests')
-rw-r--r--ext/pcre/tests/001.phpt87
-rw-r--r--ext/pcre/tests/002.phpt40
-rw-r--r--ext/pcre/tests/003.phpt140
-rw-r--r--ext/pcre/tests/004.phpt149
-rw-r--r--ext/pcre/tests/005.phpt476
-rw-r--r--ext/pcre/tests/006.phpt24
-rw-r--r--ext/pcre/tests/007.phpt59
-rw-r--r--ext/pcre/tests/backtrack_limit.phpt25
-rw-r--r--ext/pcre/tests/bug20528.phpt24
-rw-r--r--ext/pcre/tests/bug21732.phpt29
-rw-r--r--ext/pcre/tests/bug21758.phpt26
-rw-r--r--ext/pcre/tests/bug26927.phpt11
-rw-r--r--ext/pcre/tests/bug27011.phpt13
-rw-r--r--ext/pcre/tests/bug27103.phpt43
-rw-r--r--ext/pcre/tests/bug34790.phpt23
-rw-r--r--ext/pcre/tests/bug37800.phpt31
-rw-r--r--ext/pcre/tests/bug37911.phpt41
-rw-r--r--ext/pcre/tests/bug38600.phpt14
-rw-r--r--ext/pcre/tests/bug40195.phpt45
-rw-r--r--ext/pcre/tests/bug40909.phpt38
-rw-r--r--ext/pcre/tests/bug41050.phpt26
-rw-r--r--ext/pcre/tests/bug41148.phpt50
-rw-r--r--ext/pcre/tests/bug41638.phpt82
-rw-r--r--ext/pcre/tests/bug42298.phpt46
-rw-r--r--ext/pcre/tests/bug42737.phpt19
-rw-r--r--ext/pcre/tests/bug42945.phpt88
-rw-r--r--ext/pcre/tests/bug44191.phpt16
-rw-r--r--ext/pcre/tests/bug44214.phpt31
-rw-r--r--ext/pcre/tests/bug44214_2.phpt25
-rw-r--r--ext/pcre/tests/bug44925.phpt107
-rw-r--r--ext/pcre/tests/bug47229.phpt37
-rw-r--r--ext/pcre/tests/bug47662.phpt18
-rw-r--r--ext/pcre/tests/bug52732.phpt13
-rw-r--r--ext/pcre/tests/bug52971.phpt43
-rw-r--r--ext/pcre/tests/bug63055.phpt23
-rw-r--r--ext/pcre/tests/cache_limit.phpt25
-rw-r--r--ext/pcre/tests/delimiters.phpt37
-rw-r--r--ext/pcre/tests/dollar_endonly.phpt39
-rw-r--r--ext/pcre/tests/grep.phpt23
-rw-r--r--ext/pcre/tests/grep2.phpt45
-rw-r--r--ext/pcre/tests/invalid_utf8.phpt22
-rw-r--r--ext/pcre/tests/invalid_utf8_offset.phpt35
-rw-r--r--ext/pcre/tests/locales.phpt29
-rw-r--r--ext/pcre/tests/match_flags.phpt127
-rw-r--r--ext/pcre/tests/match_flags2.phpt95
-rw-r--r--ext/pcre/tests/match_flags3.phpt46
-rw-r--r--ext/pcre/tests/multiline.phpt18
-rw-r--r--ext/pcre/tests/null_bytes.phpt42
-rw-r--r--ext/pcre/tests/pcre.constants.phpt35
-rw-r--r--ext/pcre/tests/pcre_anchored.phpt28
-rw-r--r--ext/pcre/tests/pcre_count.phpt40
-rw-r--r--ext/pcre/tests/pcre_extended.phpt29
-rw-r--r--ext/pcre/tests/pcre_extra.phpt14
-rw-r--r--ext/pcre/tests/preg_filter.phpt29
-rw-r--r--ext/pcre/tests/preg_grep_basic.phpt62
-rw-r--r--ext/pcre/tests/preg_grep_error.phpt43
-rw-r--r--ext/pcre/tests/preg_grep_error1.phpt68
-rw-r--r--ext/pcre/tests/preg_grep_error2.phpt42
-rw-r--r--ext/pcre/tests/preg_last_error_error.phpt30
-rw-r--r--ext/pcre/tests/preg_match_all_basic.phpt92
-rw-r--r--ext/pcre/tests/preg_match_all_edit_basic.phpt89
-rw-r--r--ext/pcre/tests/preg_match_all_error.phpt44
-rw-r--r--ext/pcre/tests/preg_match_all_error1.phpt81
-rw-r--r--ext/pcre/tests/preg_match_all_error2.phpt54
-rw-r--r--ext/pcre/tests/preg_match_all_error3.phpt20
-rw-r--r--ext/pcre/tests/preg_match_basic.phpt52
-rw-r--r--ext/pcre/tests/preg_match_basic_002.phpt23
-rw-r--r--ext/pcre/tests/preg_match_basic_edit.phpt60
-rw-r--r--ext/pcre/tests/preg_match_error.phpt44
-rw-r--r--ext/pcre/tests/preg_match_error1.phpt61
-rw-r--r--ext/pcre/tests/preg_match_error2.phpt38
-rw-r--r--ext/pcre/tests/preg_match_variation1.phpt22
-rw-r--r--ext/pcre/tests/preg_quote_basic.phpt25
-rw-r--r--ext/pcre/tests/preg_quote_error.phpt33
-rw-r--r--ext/pcre/tests/preg_quote_error1.phpt36
-rw-r--r--ext/pcre/tests/preg_replace.phpt25
-rw-r--r--ext/pcre/tests/preg_replace2.phpt48
-rw-r--r--ext/pcre/tests/preg_replace_basic.phpt25
-rw-r--r--ext/pcre/tests/preg_replace_callback.phpt25
-rw-r--r--ext/pcre/tests/preg_replace_callback2.phpt39
-rw-r--r--ext/pcre/tests/preg_replace_callback3.phpt44
-rw-r--r--ext/pcre/tests/preg_replace_callback_basic.phpt33
-rw-r--r--ext/pcre/tests/preg_replace_callback_error.phpt48
-rw-r--r--ext/pcre/tests/preg_replace_callback_error1.phpt59
-rw-r--r--ext/pcre/tests/preg_replace_edit_basic.phpt39
-rw-r--r--ext/pcre/tests/preg_replace_error.phpt45
-rw-r--r--ext/pcre/tests/preg_replace_error1.phpt59
-rw-r--r--ext/pcre/tests/preg_replace_error2.phpt37
-rw-r--r--ext/pcre/tests/preg_replace_variation1.phpt17
-rw-r--r--ext/pcre/tests/preg_split_basic.phpt75
-rw-r--r--ext/pcre/tests/preg_split_error.phpt44
-rw-r--r--ext/pcre/tests/preg_split_error1.phpt67
-rw-r--r--ext/pcre/tests/preg_split_error2.phpt34
-rw-r--r--ext/pcre/tests/recursion_limit.phpt25
-rw-r--r--ext/pcre/tests/skip.ini17
-rw-r--r--ext/pcre/tests/skip_001.inc9
-rw-r--r--ext/pcre/tests/skip_002.inc5
-rw-r--r--ext/pcre/tests/skip_003.inc5
-rw-r--r--ext/pcre/tests/split.phpt86
-rw-r--r--ext/pcre/tests/split2.phpt315
-rw-r--r--ext/pcre/tests/study.phpt31
-rw-r--r--ext/pcre/tests/ungreedy.phpt31
102 files changed, 5026 insertions, 0 deletions
diff --git a/ext/pcre/tests/001.phpt b/ext/pcre/tests/001.phpt
new file mode 100644
index 0000000..313f7fd
--- /dev/null
+++ b/ext/pcre/tests/001.phpt
@@ -0,0 +1,87 @@
+--TEST--
+abusing preg_match()
+--FILE--
+<?php
+
+foreach (array('2006-05-13', '06-12-12', 'data: "12-Aug-87"') as $s) {
+ var_dump(preg_match('~
+ (?P<date>
+ (?P<year>(\d{2})?\d\d) -
+ (?P<month>(?:\d\d|[a-zA-Z]{2,3})) -
+ (?P<day>[0-3]?\d))
+ ~x', $s, $m));
+
+ var_dump($m);
+}
+
+?>
+--EXPECT--
+int(1)
+array(10) {
+ [0]=>
+ string(10) "2006-05-13"
+ ["date"]=>
+ string(10) "2006-05-13"
+ [1]=>
+ string(10) "2006-05-13"
+ ["year"]=>
+ string(4) "2006"
+ [2]=>
+ string(4) "2006"
+ [3]=>
+ string(2) "20"
+ ["month"]=>
+ string(2) "05"
+ [4]=>
+ string(2) "05"
+ ["day"]=>
+ string(2) "13"
+ [5]=>
+ string(2) "13"
+}
+int(1)
+array(10) {
+ [0]=>
+ string(8) "06-12-12"
+ ["date"]=>
+ string(8) "06-12-12"
+ [1]=>
+ string(8) "06-12-12"
+ ["year"]=>
+ string(2) "06"
+ [2]=>
+ string(2) "06"
+ [3]=>
+ string(0) ""
+ ["month"]=>
+ string(2) "12"
+ [4]=>
+ string(2) "12"
+ ["day"]=>
+ string(2) "12"
+ [5]=>
+ string(2) "12"
+}
+int(1)
+array(10) {
+ [0]=>
+ string(8) "12-Aug-8"
+ ["date"]=>
+ string(8) "12-Aug-8"
+ [1]=>
+ string(8) "12-Aug-8"
+ ["year"]=>
+ string(2) "12"
+ [2]=>
+ string(2) "12"
+ [3]=>
+ string(0) ""
+ ["month"]=>
+ string(3) "Aug"
+ [4]=>
+ string(3) "Aug"
+ ["day"]=>
+ string(1) "8"
+ [5]=>
+ string(1) "8"
+}
diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt
new file mode 100644
index 0000000..00f68f3
--- /dev/null
+++ b/ext/pcre/tests/002.phpt
@@ -0,0 +1,40 @@
+--TEST--
+preg_* with bogus vals
+--FILE--
+<?php
+
+var_dump(preg_match());
+var_dump(preg_match_all());
+var_dump(preg_match_all('//', '', $dummy, 0xdead));
+
+var_dump(preg_quote());
+var_dump(preg_quote(''));
+
+var_dump(preg_replace('/(.)/', '${1}${1', 'abc'));
+var_dump(preg_replace('/.++\d*+[/', 'for ($', 'abc'));
+var_dump(preg_replace('/(.)/e', 'for ($', 'abc'));
+
+?>
+--EXPECTF--
+
+Warning: preg_match() expects at least 2 parameters, 0 given in %s002.php on line 3
+bool(false)
+
+Warning: preg_match_all() expects at least 2 parameters, 0 given in %s002.php on line 4
+bool(false)
+
+Warning: preg_match_all(): Invalid flags specified in %s002.php on line 5
+NULL
+
+Warning: preg_quote() expects at least 1 parameter, 0 given in %s002.php on line 7
+NULL
+string(0) ""
+string(12) "a${1b${1c${1"
+
+Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 in %s002.php on line 11
+NULL
+
+Parse error: %s in %s002.php(12) : regexp code on line 1
+
+Fatal error: preg_replace(): Failed evaluating code:
+for ($ in %s002.php on line 12
diff --git a/ext/pcre/tests/003.phpt b/ext/pcre/tests/003.phpt
new file mode 100644
index 0000000..e697c37
--- /dev/null
+++ b/ext/pcre/tests/003.phpt
@@ -0,0 +1,140 @@
+--TEST--
+abusing preg_match_all()
+--FILE--
+<?php
+
+foreach (array(PREG_PATTERN_ORDER, PREG_SET_ORDER) as $flag) {
+ var_dump(preg_match_all('~
+ (?P<date>
+ (?P<year>(\d{2})?\d\d) -
+ (?P<month>(?:\d\d|[a-zA-Z]{2,3})) -
+ (?P<day>[0-3]?\d))
+ ~x',
+ '2006-05-13 e outra data: "12-Aug-37"', $m, $flag));
+
+ var_dump($m);
+}
+?>
+--EXPECT--
+int(2)
+array(10) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(10) "2006-05-13"
+ [1]=>
+ string(9) "12-Aug-37"
+ }
+ ["date"]=>
+ array(2) {
+ [0]=>
+ string(10) "2006-05-13"
+ [1]=>
+ string(9) "12-Aug-37"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(10) "2006-05-13"
+ [1]=>
+ string(9) "12-Aug-37"
+ }
+ ["year"]=>
+ array(2) {
+ [0]=>
+ string(4) "2006"
+ [1]=>
+ string(2) "12"
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(4) "2006"
+ [1]=>
+ string(2) "12"
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ string(2) "20"
+ [1]=>
+ string(0) ""
+ }
+ ["month"]=>
+ array(2) {
+ [0]=>
+ string(2) "05"
+ [1]=>
+ string(3) "Aug"
+ }
+ [4]=>
+ array(2) {
+ [0]=>
+ string(2) "05"
+ [1]=>
+ string(3) "Aug"
+ }
+ ["day"]=>
+ array(2) {
+ [0]=>
+ string(2) "13"
+ [1]=>
+ string(2) "37"
+ }
+ [5]=>
+ array(2) {
+ [0]=>
+ string(2) "13"
+ [1]=>
+ string(2) "37"
+ }
+}
+int(2)
+array(2) {
+ [0]=>
+ array(10) {
+ [0]=>
+ string(10) "2006-05-13"
+ ["date"]=>
+ string(10) "2006-05-13"
+ [1]=>
+ string(10) "2006-05-13"
+ ["year"]=>
+ string(4) "2006"
+ [2]=>
+ string(4) "2006"
+ [3]=>
+ string(2) "20"
+ ["month"]=>
+ string(2) "05"
+ [4]=>
+ string(2) "05"
+ ["day"]=>
+ string(2) "13"
+ [5]=>
+ string(2) "13"
+ }
+ [1]=>
+ array(10) {
+ [0]=>
+ string(9) "12-Aug-37"
+ ["date"]=>
+ string(9) "12-Aug-37"
+ [1]=>
+ string(9) "12-Aug-37"
+ ["year"]=>
+ string(2) "12"
+ [2]=>
+ string(2) "12"
+ [3]=>
+ string(0) ""
+ ["month"]=>
+ string(3) "Aug"
+ [4]=>
+ string(3) "Aug"
+ ["day"]=>
+ string(2) "37"
+ [5]=>
+ string(2) "37"
+ }
+}
diff --git a/ext/pcre/tests/004.phpt b/ext/pcre/tests/004.phpt
new file mode 100644
index 0000000..b1e9586
--- /dev/null
+++ b/ext/pcre/tests/004.phpt
@@ -0,0 +1,149 @@
+--TEST--
+abusing pcre
+--FILE--
+<?php
+
+var_dump(preg_match_all('/((?:(?:unsigned|struct)\s+)?\w+)(?:\s*(\*+)\s+|\s+(\**))(\w+(?:\[\s*\w*\s*\])?)\s*(?:(=)[^,;]+)?((?:\s*,\s*\**\s*\w+(?:\[\s*\w*\s*\])?\s*(?:=[^,;]+)?)*)\s*;/S', 'unsigned int xpto = 124; short a, b;', $m, PREG_SET_ORDER));
+var_dump($m);
+
+var_dump(preg_match_all('/(?:\([^)]+\))?(&?)([\w>.()-]+(?:\[\w+\])?)\s*,?((?:\)*\s*=)?)/S', '&a, b, &c', $m, PREG_SET_ORDER));
+var_dump($m);
+
+var_dump(preg_match_all('/zend_parse_parameters(?:_ex\s*\([^,]+,[^,]+|\s*\([^,]+),\s*"([^"]*)"\s*,\s*([^{;]*)/S', 'zend_parse_parameters( 0, "addd|s/", a, b, &c);', $m, PREG_SET_ORDER | PREG_OFFSET_CAPTURE));
+var_dump($m);
+
+var_dump(preg_replace(array('@//.*@S', '@/\*.*\*/@SsUe'), array('', 'preg_replace("/[^\r\n]+/S", "", \'$0\')'), "hello\n//x \n/*\ns\n*/"));
+
+var_dump(preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', "PHP_FUNCTION(s, preg_match)\n{\nlalala", -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
+?>
+--EXPECT--
+int(2)
+array(2) {
+ [0]=>
+ array(7) {
+ [0]=>
+ string(24) "unsigned int xpto = 124;"
+ [1]=>
+ string(12) "unsigned int"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(4) "xpto"
+ [5]=>
+ string(1) "="
+ [6]=>
+ string(0) ""
+ }
+ [1]=>
+ array(7) {
+ [0]=>
+ string(11) "short a, b;"
+ [1]=>
+ string(5) "short"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(1) "a"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(3) ", b"
+ }
+}
+int(3)
+array(3) {
+ [0]=>
+ array(4) {
+ [0]=>
+ string(3) "&a,"
+ [1]=>
+ string(1) "&"
+ [2]=>
+ string(1) "a"
+ [3]=>
+ string(0) ""
+ }
+ [1]=>
+ array(4) {
+ [0]=>
+ string(2) "b,"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(1) "b"
+ [3]=>
+ string(0) ""
+ }
+ [2]=>
+ array(4) {
+ [0]=>
+ string(2) "&c"
+ [1]=>
+ string(1) "&"
+ [2]=>
+ string(1) "c"
+ [3]=>
+ string(0) ""
+ }
+}
+int(1)
+array(1) {
+ [0]=>
+ array(3) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(46) "zend_parse_parameters( 0, "addd|s/", a, b, &c)"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(7) "addd|s/"
+ [1]=>
+ int(27)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(9) "a, b, &c)"
+ [1]=>
+ int(37)
+ }
+ }
+}
+string(9) "hello
+
+
+
+"
+array(3) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(13) "s, preg_match"
+ [1]=>
+ int(13)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(9) "
+{
+lalala"
+ [1]=>
+ int(27)
+ }
+}
diff --git a/ext/pcre/tests/005.phpt b/ext/pcre/tests/005.phpt
new file mode 100644
index 0000000..5eff83e
--- /dev/null
+++ b/ext/pcre/tests/005.phpt
@@ -0,0 +1,476 @@
+--TEST--
+abusing preg_match_all() #2
+--FILE--
+<?php
+// this file is not used in the cron job
+// use it to test the gcc regex with the sample data provided
+
+$sampledata = "
+/p2/var/php_gcov/PHP_4_4/ext/ming/ming.c: In function `zif_swfbitmap_init':
+/p2/var/php_gcov/PHP_4_4/ext/ming/ming.c:323: warning: assignment from incompatible pointer type
+/p2/var/php_gcov/PHP_4_4/ext/ming/ming.c: In function `zif_swftextfield_setFont':
+/p2/var/php_gcov/PHP_4_4/ext/ming/ming.c:2597: warning: passing arg 2 of `SWFTextField_setFont' from incompatible pointer type
+/p2/var/php_gcov/PHP_4_4/ext/oci8/oci8.c:1027: warning: `oci_ping' defined but not used
+/p2/var/php_gcov/PHP_4_4/ext/posix/posix.c: In function `zif_posix_getpgid':
+/p2/var/php_gcov/PHP_4_4/ext/posix/posix.c:484: warning: implicit declaration of function `getpgid'
+/p2/var/php_gcov/PHP_4_4/ext/posix/posix.c: In function `zif_posix_getsid':
+/p2/var/php_gcov/PHP_4_4/ext/posix/posix.c:506: warning: implicit declaration of function `getsid'
+/p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c: In function `ps_read_files':
+/p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c:302: warning: implicit declaration of function `pread'
+/p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c: In function `ps_write_files':
+/p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c:340: warning: implicit declaration of function `pwrite'
+/p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c: In function `zif_socket_get_option':
+/p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c:1862: warning: unused variable `timeout'
+/p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c: In function `zif_socket_set_option':
+/p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c:1941: warning: unused variable `timeout'
+/p2/var/php_gcov/PHP_4_4/regex/regexec.c:19: warning: `nope' defined but not used
+/p2/var/php_gcov/PHP_4_4/ext/standard/exec.c:50: warning: `php_make_safe_mode_command' defined but not used
+/p2/var/php_gcov/PHP_4_4/ext/standard/image.c: In function `php_handle_jpc':
+/p2/var/php_gcov/PHP_4_4/ext/standard/image.c:604: warning: unused variable `dummy_int'
+/p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c: In function `php_gd_parse':
+/p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c:1138: warning: implicit declaration of function `php_gd_lex'
+/p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.y: At top level:
+/p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.y:864: warning: return type defaults to `int'
+/p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c: In function `zif_msg_receive':
+/p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c:318: warning: passing arg 2 of `php_var_unserialize' from incompatible pointer type
+/p2/var/php_gcov/PHP_4_4/ext/yp/yp.c: In function `zif_yp_err_string':
+/p2/var/php_gcov/PHP_4_4/ext/yp/yp.c:372: warning: assignment discards qualifiers from pointer target type
+Zend/zend_language_scanner.c:5944: warning: `yy_fatal_error' defined but not used
+Zend/zend_language_scanner.c:2627: warning: `yy_last_accepting_state' defined but not used
+Zend/zend_language_scanner.c:2628: warning: `yy_last_accepting_cpos' defined but not used
+Zend/zend_language_scanner.c:2634: warning: `yy_more_flag' defined but not used
+Zend/zend_language_scanner.c:2635: warning: `yy_more_len' defined but not used
+Zend/zend_language_scanner.c:5483: warning: `yyunput' defined but not used
+Zend/zend_language_scanner.c:5929: warning: `yy_top_state' defined but not used
+conflicts: 2 shift/reduce
+Zend/zend_ini_scanner.c:457: warning: `yy_last_accepting_state' defined but not used
+Zend/zend_ini_scanner.c:458: warning: `yy_last_accepting_cpos' defined but not used
+Zend/zend_ini_scanner.c:1361: warning: `yyunput' defined but not used
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c: In function `_safe_emalloc':
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c:237: warning: long int format, size_t arg (arg 3)
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c:237: warning: long int format, size_t arg (arg 4)
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c:237: warning: long int format, size_t arg (arg 5)
+/p2/var/php_gcov/PHP_4_4/Zend/zend_ini.c:338: warning: `zend_ini_displayer_cb' defined but not used
+ext/mysql/libmysql/my_tempnam.o(.text+0x80): In function `my_tempnam':
+/p2/var/php_gcov/PHP_4_4/ext/mysql/libmysql/my_tempnam.c:115: warning: the use of `tempnam' is dangerous, better use `mkstemp'
+ext/mysql/libmysql/my_tempnam.o(.text+0x80): In function `my_tempnam':
+/p2/var/php_gcov/PHP_4_4/ext/mysql/libmysql/my_tempnam.c:115: warning: the use of `tempnam' is dangerous, better use `mkstemp'
+ext/ming/ming.o(.text+0xc115): In function `zim_swfmovie_namedAnchor':
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:2207: undefined reference to `SWFMovie_namedAnchor'
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:2209: undefined reference to `SWFMovie_xpto'
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:2259: undefined reference to `SWFMovie_foo'
+ext/ming/ming.o(.text+0x851): In function `zif_ming_setSWFCompression':
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:154: undefined reference to `Ming_setSWFCompression'
+";
+
+ // Regular expression to select the error and warning information
+ // tuned for gcc 3.4, 4.0 and 4.1
+ $gcc_regex = '/^((.+)(\(\.text\+0x[[:xdigit:]]+\))?: In function [`\'](\w+)\':\s+)?'.
+ '((?(1)(?(3)[^:\n]+|\2)|[^:\n]+)):(\d+): (?:(error|warning):\s+)?(.+)'.
+ str_repeat('(?:\s+\5:(\d+): (?:(error|warning):\s+)?(.+))?', 99). // capture up to 100 errors
+ '/mS';
+
+
+var_dump(preg_match_all($gcc_regex, $sampledata, $m, PREG_SET_ORDER));
+print_r($m);
+
+?>
+--EXPECT--
+int(24)
+Array
+(
+ [0] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c: In function `zif_swfbitmap_init':
+/p2/var/php_gcov/PHP_4_4/ext/ming/ming.c:323: warning: assignment from incompatible pointer type
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c: In function `zif_swfbitmap_init':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c
+ [3] =>
+ [4] => zif_swfbitmap_init
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c
+ [6] => 323
+ [7] => warning
+ [8] => assignment from incompatible pointer type
+ )
+
+ [1] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c: In function `zif_swftextfield_setFont':
+/p2/var/php_gcov/PHP_4_4/ext/ming/ming.c:2597: warning: passing arg 2 of `SWFTextField_setFont' from incompatible pointer type
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c: In function `zif_swftextfield_setFont':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c
+ [3] =>
+ [4] => zif_swftextfield_setFont
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/ming/ming.c
+ [6] => 2597
+ [7] => warning
+ [8] => passing arg 2 of `SWFTextField_setFont' from incompatible pointer type
+ )
+
+ [2] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/oci8/oci8.c:1027: warning: `oci_ping' defined but not used
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/oci8/oci8.c
+ [6] => 1027
+ [7] => warning
+ [8] => `oci_ping' defined but not used
+ )
+
+ [3] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c: In function `zif_posix_getpgid':
+/p2/var/php_gcov/PHP_4_4/ext/posix/posix.c:484: warning: implicit declaration of function `getpgid'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c: In function `zif_posix_getpgid':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c
+ [3] =>
+ [4] => zif_posix_getpgid
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c
+ [6] => 484
+ [7] => warning
+ [8] => implicit declaration of function `getpgid'
+ )
+
+ [4] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c: In function `zif_posix_getsid':
+/p2/var/php_gcov/PHP_4_4/ext/posix/posix.c:506: warning: implicit declaration of function `getsid'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c: In function `zif_posix_getsid':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c
+ [3] =>
+ [4] => zif_posix_getsid
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/posix/posix.c
+ [6] => 506
+ [7] => warning
+ [8] => implicit declaration of function `getsid'
+ )
+
+ [5] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c: In function `ps_read_files':
+/p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c:302: warning: implicit declaration of function `pread'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c: In function `ps_read_files':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c
+ [3] =>
+ [4] => ps_read_files
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c
+ [6] => 302
+ [7] => warning
+ [8] => implicit declaration of function `pread'
+ )
+
+ [6] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c: In function `ps_write_files':
+/p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c:340: warning: implicit declaration of function `pwrite'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c: In function `ps_write_files':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c
+ [3] =>
+ [4] => ps_write_files
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/session/mod_files.c
+ [6] => 340
+ [7] => warning
+ [8] => implicit declaration of function `pwrite'
+ )
+
+ [7] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c: In function `zif_socket_get_option':
+/p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c:1862: warning: unused variable `timeout'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c: In function `zif_socket_get_option':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c
+ [3] =>
+ [4] => zif_socket_get_option
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c
+ [6] => 1862
+ [7] => warning
+ [8] => unused variable `timeout'
+ )
+
+ [8] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c: In function `zif_socket_set_option':
+/p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c:1941: warning: unused variable `timeout'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c: In function `zif_socket_set_option':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c
+ [3] =>
+ [4] => zif_socket_set_option
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/sockets/sockets.c
+ [6] => 1941
+ [7] => warning
+ [8] => unused variable `timeout'
+ )
+
+ [9] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/regex/regexec.c:19: warning: `nope' defined but not used
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => /p2/var/php_gcov/PHP_4_4/regex/regexec.c
+ [6] => 19
+ [7] => warning
+ [8] => `nope' defined but not used
+ )
+
+ [10] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/standard/exec.c:50: warning: `php_make_safe_mode_command' defined but not used
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/standard/exec.c
+ [6] => 50
+ [7] => warning
+ [8] => `php_make_safe_mode_command' defined but not used
+ )
+
+ [11] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/standard/image.c: In function `php_handle_jpc':
+/p2/var/php_gcov/PHP_4_4/ext/standard/image.c:604: warning: unused variable `dummy_int'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/standard/image.c: In function `php_handle_jpc':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/standard/image.c
+ [3] =>
+ [4] => php_handle_jpc
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/standard/image.c
+ [6] => 604
+ [7] => warning
+ [8] => unused variable `dummy_int'
+ )
+
+ [12] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c: In function `php_gd_parse':
+/p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c:1138: warning: implicit declaration of function `php_gd_lex'
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c: In function `php_gd_parse':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c
+ [3] =>
+ [4] => php_gd_parse
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.c
+ [6] => 1138
+ [7] => warning
+ [8] => implicit declaration of function `php_gd_lex'
+ )
+
+ [13] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.y:864: warning: return type defaults to `int'
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/standard/parsedate.y
+ [6] => 864
+ [7] => warning
+ [8] => return type defaults to `int'
+ )
+
+ [14] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c: In function `zif_msg_receive':
+/p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c:318: warning: passing arg 2 of `php_var_unserialize' from incompatible pointer type
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c: In function `zif_msg_receive':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c
+ [3] =>
+ [4] => zif_msg_receive
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/sysvmsg/sysvmsg.c
+ [6] => 318
+ [7] => warning
+ [8] => passing arg 2 of `php_var_unserialize' from incompatible pointer type
+ )
+
+ [15] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/ext/yp/yp.c: In function `zif_yp_err_string':
+/p2/var/php_gcov/PHP_4_4/ext/yp/yp.c:372: warning: assignment discards qualifiers from pointer target type
+ [1] => /p2/var/php_gcov/PHP_4_4/ext/yp/yp.c: In function `zif_yp_err_string':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/ext/yp/yp.c
+ [3] =>
+ [4] => zif_yp_err_string
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/yp/yp.c
+ [6] => 372
+ [7] => warning
+ [8] => assignment discards qualifiers from pointer target type
+ )
+
+ [16] => Array
+ (
+ [0] => Zend/zend_language_scanner.c:5944: warning: `yy_fatal_error' defined but not used
+Zend/zend_language_scanner.c:2627: warning: `yy_last_accepting_state' defined but not used
+Zend/zend_language_scanner.c:2628: warning: `yy_last_accepting_cpos' defined but not used
+Zend/zend_language_scanner.c:2634: warning: `yy_more_flag' defined but not used
+Zend/zend_language_scanner.c:2635: warning: `yy_more_len' defined but not used
+Zend/zend_language_scanner.c:5483: warning: `yyunput' defined but not used
+Zend/zend_language_scanner.c:5929: warning: `yy_top_state' defined but not used
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => Zend/zend_language_scanner.c
+ [6] => 5944
+ [7] => warning
+ [8] => `yy_fatal_error' defined but not used
+ [9] => 2627
+ [10] => warning
+ [11] => `yy_last_accepting_state' defined but not used
+ [12] => 2628
+ [13] => warning
+ [14] => `yy_last_accepting_cpos' defined but not used
+ [15] => 2634
+ [16] => warning
+ [17] => `yy_more_flag' defined but not used
+ [18] => 2635
+ [19] => warning
+ [20] => `yy_more_len' defined but not used
+ [21] => 5483
+ [22] => warning
+ [23] => `yyunput' defined but not used
+ [24] => 5929
+ [25] => warning
+ [26] => `yy_top_state' defined but not used
+ )
+
+ [17] => Array
+ (
+ [0] => Zend/zend_ini_scanner.c:457: warning: `yy_last_accepting_state' defined but not used
+Zend/zend_ini_scanner.c:458: warning: `yy_last_accepting_cpos' defined but not used
+Zend/zend_ini_scanner.c:1361: warning: `yyunput' defined but not used
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => Zend/zend_ini_scanner.c
+ [6] => 457
+ [7] => warning
+ [8] => `yy_last_accepting_state' defined but not used
+ [9] => 458
+ [10] => warning
+ [11] => `yy_last_accepting_cpos' defined but not used
+ [12] => 1361
+ [13] => warning
+ [14] => `yyunput' defined but not used
+ )
+
+ [18] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c: In function `_safe_emalloc':
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c:237: warning: long int format, size_t arg (arg 3)
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c:237: warning: long int format, size_t arg (arg 4)
+/p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c:237: warning: long int format, size_t arg (arg 5)
+ [1] => /p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c: In function `_safe_emalloc':
+
+ [2] => /p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c
+ [3] =>
+ [4] => _safe_emalloc
+ [5] => /p2/var/php_gcov/PHP_4_4/Zend/zend_alloc.c
+ [6] => 237
+ [7] => warning
+ [8] => long int format, size_t arg (arg 3)
+ [9] => 237
+ [10] => warning
+ [11] => long int format, size_t arg (arg 4)
+ [12] => 237
+ [13] => warning
+ [14] => long int format, size_t arg (arg 5)
+ )
+
+ [19] => Array
+ (
+ [0] => /p2/var/php_gcov/PHP_4_4/Zend/zend_ini.c:338: warning: `zend_ini_displayer_cb' defined but not used
+ [1] =>
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] => /p2/var/php_gcov/PHP_4_4/Zend/zend_ini.c
+ [6] => 338
+ [7] => warning
+ [8] => `zend_ini_displayer_cb' defined but not used
+ )
+
+ [20] => Array
+ (
+ [0] => ext/mysql/libmysql/my_tempnam.o(.text+0x80): In function `my_tempnam':
+/p2/var/php_gcov/PHP_4_4/ext/mysql/libmysql/my_tempnam.c:115: warning: the use of `tempnam' is dangerous, better use `mkstemp'
+ [1] => ext/mysql/libmysql/my_tempnam.o(.text+0x80): In function `my_tempnam':
+
+ [2] => ext/mysql/libmysql/my_tempnam.o
+ [3] => (.text+0x80)
+ [4] => my_tempnam
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/mysql/libmysql/my_tempnam.c
+ [6] => 115
+ [7] => warning
+ [8] => the use of `tempnam' is dangerous, better use `mkstemp'
+ )
+
+ [21] => Array
+ (
+ [0] => ext/mysql/libmysql/my_tempnam.o(.text+0x80): In function `my_tempnam':
+/p2/var/php_gcov/PHP_4_4/ext/mysql/libmysql/my_tempnam.c:115: warning: the use of `tempnam' is dangerous, better use `mkstemp'
+ [1] => ext/mysql/libmysql/my_tempnam.o(.text+0x80): In function `my_tempnam':
+
+ [2] => ext/mysql/libmysql/my_tempnam.o
+ [3] => (.text+0x80)
+ [4] => my_tempnam
+ [5] => /p2/var/php_gcov/PHP_4_4/ext/mysql/libmysql/my_tempnam.c
+ [6] => 115
+ [7] => warning
+ [8] => the use of `tempnam' is dangerous, better use `mkstemp'
+ )
+
+ [22] => Array
+ (
+ [0] => ext/ming/ming.o(.text+0xc115): In function `zim_swfmovie_namedAnchor':
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:2207: undefined reference to `SWFMovie_namedAnchor'
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:2209: undefined reference to `SWFMovie_xpto'
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:2259: undefined reference to `SWFMovie_foo'
+ [1] => ext/ming/ming.o(.text+0xc115): In function `zim_swfmovie_namedAnchor':
+
+ [2] => ext/ming/ming.o
+ [3] => (.text+0xc115)
+ [4] => zim_swfmovie_namedAnchor
+ [5] => /p2/var/php_gcov/PHP_5_2/ext/ming/ming.c
+ [6] => 2207
+ [7] =>
+ [8] => undefined reference to `SWFMovie_namedAnchor'
+ [9] => 2209
+ [10] =>
+ [11] => undefined reference to `SWFMovie_xpto'
+ [12] => 2259
+ [13] =>
+ [14] => undefined reference to `SWFMovie_foo'
+ )
+
+ [23] => Array
+ (
+ [0] => ext/ming/ming.o(.text+0x851): In function `zif_ming_setSWFCompression':
+/p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:154: undefined reference to `Ming_setSWFCompression'
+ [1] => ext/ming/ming.o(.text+0x851): In function `zif_ming_setSWFCompression':
+
+ [2] => ext/ming/ming.o
+ [3] => (.text+0x851)
+ [4] => zif_ming_setSWFCompression
+ [5] => /p2/var/php_gcov/PHP_5_2/ext/ming/ming.c
+ [6] => 154
+ [7] =>
+ [8] => undefined reference to `Ming_setSWFCompression'
+ )
+
+)
diff --git a/ext/pcre/tests/006.phpt b/ext/pcre/tests/006.phpt
new file mode 100644
index 0000000..2d39b6e
--- /dev/null
+++ b/ext/pcre/tests/006.phpt
@@ -0,0 +1,24 @@
+--TEST--
+preg_replace() with array of failing regular expressions
+--INI--
+pcre.backtrack_limit=100000
+--FILE--
+<?php
+
+$text = '[CODE]&lt;td align=&quot;$stylevar[right]&quot;&gt;[/CODE]';
+$result = preg_replace(array('#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU', '#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU'), '', $text);
+var_dump($text);
+var_dump($result);
+
+$result = preg_replace('#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU', '', $text);
+var_dump($text);
+var_dump($result);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(58) "[CODE]&lt;td align=&quot;$stylevar[right]&quot;&gt;[/CODE]"
+NULL
+string(58) "[CODE]&lt;td align=&quot;$stylevar[right]&quot;&gt;[/CODE]"
+NULL
+Done
diff --git a/ext/pcre/tests/007.phpt b/ext/pcre/tests/007.phpt
new file mode 100644
index 0000000..776bec2
--- /dev/null
+++ b/ext/pcre/tests/007.phpt
@@ -0,0 +1,59 @@
+--TEST--
+preg_replace_callback() with callback that modifies subject string
+--SKIPIF--
+<?php
+if (@preg_match('/./u', '') === false) {
+ die('skip no utf8 support in PCRE library');
+}
+?>
+--FILE--
+<?php
+
+function evil($x) {
+ global $txt;
+ $txt[3] = "\xFF";
+ var_dump($x);
+ return $x[0];
+}
+
+$txt = "ola123";
+var_dump(preg_replace_callback('#.#u', 'evil', $txt));
+var_dump($txt);
+var_dump(preg_last_error() == PREG_NO_ERROR);
+
+var_dump(preg_replace_callback('#.#u', 'evil', $txt));
+var_dump(preg_last_error() == PREG_BAD_UTF8_ERROR);
+
+echo "Done!\n";
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "o"
+}
+array(1) {
+ [0]=>
+ string(1) "l"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+string(6) "ola123"
+string(6) "olaÿ23"
+bool(true)
+NULL
+bool(true)
+Done!
diff --git a/ext/pcre/tests/backtrack_limit.phpt b/ext/pcre/tests/backtrack_limit.phpt
new file mode 100644
index 0000000..419e6c2
--- /dev/null
+++ b/ext/pcre/tests/backtrack_limit.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Backtracking limit
+--SKIPIF--
+<?php
+if (@preg_match_all('/\p{N}/', '0123456789', $dummy) === false) {
+ die("skip no support for \p support PCRE library");
+}
+?>
+--INI--
+pcre.backtrack_limit=2
+--FILE--
+<?php
+
+var_dump(preg_match_all('/.*\p{N}/', '0123456789', $dummy));
+var_dump(preg_last_error() === PREG_BACKTRACK_LIMIT_ERROR);
+
+var_dump(preg_match_all('/\p{Nd}/', '0123456789', $dummy));
+var_dump(preg_last_error() === PREG_NO_ERROR);
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
+int(10)
+bool(true)
diff --git a/ext/pcre/tests/bug20528.phpt b/ext/pcre/tests/bug20528.phpt
new file mode 100644
index 0000000..8182fd9
--- /dev/null
+++ b/ext/pcre/tests/bug20528.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #20528 (preg_split() drops characters (re-opens Bug #15413))
+--FILE--
+<?php
+ $data = '(#11/19/2002#)';
+ var_dump(preg_split('/\b/', $data));
+?>
+--EXPECT--
+array(7) {
+ [0]=>
+ string(2) "(#"
+ [1]=>
+ string(2) "11"
+ [2]=>
+ string(1) "/"
+ [3]=>
+ string(2) "19"
+ [4]=>
+ string(1) "/"
+ [5]=>
+ string(4) "2002"
+ [6]=>
+ string(2) "#)"
+}
diff --git a/ext/pcre/tests/bug21732.phpt b/ext/pcre/tests/bug21732.phpt
new file mode 100644
index 0000000..3dfc41e
--- /dev/null
+++ b/ext/pcre/tests/bug21732.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #21732 (preg_replace() segfaults with invalid parameters)
+--INI--
+error_reporting=0
+--FILE--
+<?php
+class foo {
+ function cb($param) {
+ var_dump($param);
+ return "yes!";
+ }
+}
+
+var_dump(preg_replace('', array(), ''));
+var_dump(preg_replace_callback("/(ab)(cd)(e)/", array(new foo(), "cb"), 'abcde'));
+?>
+--EXPECT--
+bool(false)
+array(4) {
+ [0]=>
+ string(5) "abcde"
+ [1]=>
+ string(2) "ab"
+ [2]=>
+ string(2) "cd"
+ [3]=>
+ string(1) "e"
+}
+string(4) "yes!"
diff --git a/ext/pcre/tests/bug21758.phpt b/ext/pcre/tests/bug21758.phpt
new file mode 100644
index 0000000..78a1d6a
--- /dev/null
+++ b/ext/pcre/tests/bug21758.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #21758 (preg_replace_callback() not working with class methods)
+--FILE--
+<?php
+ class Foo {
+ function foo() {
+
+ $s = 'preg_replace() is broken';
+
+ var_dump(preg_replace_callback(
+ '/broken/',
+ array(&$this, 'bar'),
+ $s
+ ));
+ }
+
+ function bar() {
+ return 'working';
+ }
+
+ } // of Foo
+
+ $o = new Foo;
+?>
+--EXPECT--
+string(25) "preg_replace() is working"
diff --git a/ext/pcre/tests/bug26927.phpt b/ext/pcre/tests/bug26927.phpt
new file mode 100644
index 0000000..5c64deb
--- /dev/null
+++ b/ext/pcre/tests/bug26927.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #26927 (preg_quote() does not escape \0)
+--FILE--
+<?php
+ $str = "a\000b";
+ $str_quoted = preg_quote($str);
+ var_dump(preg_match("!{$str_quoted}!", $str), $str_quoted);
+?>
+--EXPECT--
+int(1)
+string(6) "a\000b"
diff --git a/ext/pcre/tests/bug27011.phpt b/ext/pcre/tests/bug27011.phpt
new file mode 100644
index 0000000..6fa88ef
--- /dev/null
+++ b/ext/pcre/tests/bug27011.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #27011 (segfault in preg_match_all())
+--FILE--
+<?php
+
+var_dump(preg_match_all('|(\w+)://([^\s"<]*[\w+#?/&=])|', "This is a text string", $matches, PREG_SET_ORDER));
+var_dump($matches);
+
+?>
+--EXPECT--
+int(0)
+array(0) {
+}
diff --git a/ext/pcre/tests/bug27103.phpt b/ext/pcre/tests/bug27103.phpt
new file mode 100644
index 0000000..163dc9f
--- /dev/null
+++ b/ext/pcre/tests/bug27103.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #27103 (preg_split('//u') incorrectly splits UTF-8 strings into octets)
+--SKIPIF--
+<?php
+if (@preg_match('/./u', '') === false) {
+ die('skip no utf8 support in PCRE library');
+}
+?>
+--FILE--
+<?php
+function iter($ar)
+{
+ foreach ($ar as $c) {
+ echo htmlentities($c, 0, "UTF-8"), ": ", strlen($c), "\n";
+ }
+}
+$teststr = "\xe2\x82\xac hi there";
+iter(preg_split('//u', $teststr, -1, PREG_SPLIT_NO_EMPTY));
+preg_match_all('/./u', $teststr, $matches);
+iter($matches[0]);
+?>
+--EXPECT--
+&euro;: 3
+ : 1
+h: 1
+i: 1
+ : 1
+t: 1
+h: 1
+e: 1
+r: 1
+e: 1
+&euro;: 3
+ : 1
+h: 1
+i: 1
+ : 1
+t: 1
+h: 1
+e: 1
+r: 1
+e: 1
+
diff --git a/ext/pcre/tests/bug34790.phpt b/ext/pcre/tests/bug34790.phpt
new file mode 100644
index 0000000..c375ae5
--- /dev/null
+++ b/ext/pcre/tests/bug34790.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #34790 (preg_match_all(), named capturing groups, variable assignment/return => crash)
+--FILE--
+<?php
+function func1(){
+ $string = 'what the word and the other word the';
+ preg_match_all('/(?P<word>the)/', $string, $matches);
+ return $matches['word'];
+}
+$words = func1();
+var_dump($words);
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ string(3) "the"
+ [1]=>
+ string(3) "the"
+ [2]=>
+ string(3) "the"
+ [3]=>
+ string(3) "the"
+}
diff --git a/ext/pcre/tests/bug37800.phpt b/ext/pcre/tests/bug37800.phpt
new file mode 100644
index 0000000..e8a0036
--- /dev/null
+++ b/ext/pcre/tests/bug37800.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #37800 (preg_replace() limit parameter odd behaviour)
+--FILE--
+<?php
+$s_string = '1111111111';
+$s_search = '/1/';
+$s_replace = 'One ';
+$i_limit = 1;
+$i_count = 0;
+
+$s_output = preg_replace($s_search, $s_replace, $s_string, $i_limit,
+$i_count);
+echo "Output = " . var_export($s_output, True) . "\n";
+echo "Count = $i_count\n";
+var_dump(preg_last_error() === PREG_NO_ERROR);
+
+$i_limit = strlen($s_string);
+$s_output = preg_replace($s_search, $s_replace, $s_string, $i_limit,
+$i_count);
+echo "Output = " . var_export($s_output, True) . "\n";
+echo "Count = $i_count\n";
+var_dump(preg_last_error() === PREG_NO_ERROR);
+
+?>
+--EXPECT--
+Output = 'One 111111111'
+Count = 1
+bool(true)
+Output = 'One One One One One One One One One One '
+Count = 10
+bool(true)
diff --git a/ext/pcre/tests/bug37911.phpt b/ext/pcre/tests/bug37911.phpt
new file mode 100644
index 0000000..f788119
--- /dev/null
+++ b/ext/pcre/tests/bug37911.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #37911 (preg_replace_callback ignores named groups)
+--FILE--
+<?php
+
+function callback($match)
+{
+ var_dump($match);
+ return $match[1].'/'.strlen($match['name']);
+}
+
+var_dump(preg_replace_callback('|(?P<name>blub)|', 'callback', 'bla blub blah'));
+
+var_dump(preg_match('|(?P<name>blub)|', 'bla blub blah', $m));
+var_dump($m);
+
+var_dump(preg_replace_callback('|(?P<1>blub)|', 'callback', 'bla blub blah'));
+
+?>
+--EXPECTF--
+array(3) {
+ [0]=>
+ string(4) "blub"
+ ["name"]=>
+ string(4) "blub"
+ [1]=>
+ string(4) "blub"
+}
+string(15) "bla blub/4 blah"
+int(1)
+array(3) {
+ [0]=>
+ string(4) "blub"
+ ["name"]=>
+ string(4) "blub"
+ [1]=>
+ string(4) "blub"
+}
+
+Warning: preg_replace_callback(): Numeric named subpatterns are not allowed in %sbug37911.php on line 14
+NULL
diff --git a/ext/pcre/tests/bug38600.phpt b/ext/pcre/tests/bug38600.phpt
new file mode 100644
index 0000000..fc954e4
--- /dev/null
+++ b/ext/pcre/tests/bug38600.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #38600 (infinite loop in pcre with extended class)
+--FILE--
+<?php
+$foo = 'bla bla bla';
+
+var_dump(preg_match('/(?<!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/', $foo, $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(0)
+array(0) {
+}
diff --git a/ext/pcre/tests/bug40195.phpt b/ext/pcre/tests/bug40195.phpt
new file mode 100644
index 0000000..87ebf42
--- /dev/null
+++ b/ext/pcre/tests/bug40195.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Bug #40195 (pcre 6.7 regression)
+--FILE--
+<?php
+
+var_dump(preg_match('@^(/([a-z]*))*$@', '//abcde', $m)); var_dump($m);
+var_dump(preg_match('@^(/(?:[a-z]*))*$@', '//abcde', $m)); var_dump($m);
+
+var_dump(preg_match('@^(/([a-z]+))+$@', '/a/abcde', $m)); var_dump($m);
+var_dump(preg_match('@^(/(?:[a-z]+))+$@', '/a/abcde', $m)); var_dump($m);
+
+?>
+--EXPECT--
+int(1)
+array(3) {
+ [0]=>
+ string(7) "//abcde"
+ [1]=>
+ string(6) "/abcde"
+ [2]=>
+ string(5) "abcde"
+}
+int(1)
+array(2) {
+ [0]=>
+ string(7) "//abcde"
+ [1]=>
+ string(6) "/abcde"
+}
+int(1)
+array(3) {
+ [0]=>
+ string(8) "/a/abcde"
+ [1]=>
+ string(6) "/abcde"
+ [2]=>
+ string(5) "abcde"
+}
+int(1)
+array(2) {
+ [0]=>
+ string(8) "/a/abcde"
+ [1]=>
+ string(6) "/abcde"
+}
diff --git a/ext/pcre/tests/bug40909.phpt b/ext/pcre/tests/bug40909.phpt
new file mode 100644
index 0000000..f66a8f9
--- /dev/null
+++ b/ext/pcre/tests/bug40909.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #40909 (pcre 7.0 regression)
+--FILE--
+<?php
+
+$pattern =
+"/\s([\w_\.\/]+)(?:=([\'\"]?(?:[\w\d\s\?=\(\)\.,'_#\/\\:;&-]|(?:\\\\\"|\\\')?)+[\'\"]?))?/";
+$context = "<simpletag an_attribute=\"simpleValueInside\">";
+
+$match = array();
+
+if ($result =preg_match_all($pattern, $context, $match))
+{
+
+var_dump($result);
+var_dump($match);
+}
+
+?>
+--EXPECT--
+int(1)
+array(3) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(33) " an_attribute="simpleValueInside""
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(12) "an_attribute"
+ }
+ [2]=>
+ array(1) {
+ [0]=>
+ string(19) ""simpleValueInside""
+ }
+}
diff --git a/ext/pcre/tests/bug41050.phpt b/ext/pcre/tests/bug41050.phpt
new file mode 100644
index 0000000..ff58e11
--- /dev/null
+++ b/ext/pcre/tests/bug41050.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #41050 (pcre 7.0 regression)
+--FILE--
+<?php
+// by legolas558
+
+$regex = '/(insert|drop|create|select|delete|update)([^;\']*('."('[^']*')+".')?)*(;|$)/i';
+
+$sql = 'SELECT * FROM #__components';
+
+if (preg_match($regex,$sql, $m)) echo 'matched';
+else echo 'not matched';
+
+print_r($m);
+
+?>
+--EXPECT--
+matchedArray
+(
+ [0] => SELECT * FROM #__components
+ [1] => SELECT
+ [2] =>
+ [3] =>
+ [4] =>
+ [5] =>
+)
diff --git a/ext/pcre/tests/bug41148.phpt b/ext/pcre/tests/bug41148.phpt
new file mode 100644
index 0000000..f0a7937
--- /dev/null
+++ b/ext/pcre/tests/bug41148.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Bug #41148 (pcre 7.0 regression)
+--FILE--
+<?php
+
+ $letexte="<br><br>";
+ $ligne_horizontale = $puce = $debut_intertitre = $fin_intertitre = '';
+
+ $cherche1 = array(
+ /* 0 */ "/\n(----+|____+)/S",
+ /* 1 */ "/\n-- */S",
+ /* 2 */ "/\n- */S",
+ /* 3 */ "/\n_ +/S",
+ /* 4 */ "/(^|[^{])[{][{][{]/S",
+ /* 5 */ "/[}][}][}]($|[^}])/S",
+ /* 6 */ "/(( *)\n){2,}(<br[[:space:]]*\/?".">)?/S",
+ /* 7 */ "/[{][{]/S",
+ /* 8 */ "/[}][}]/S",
+ /* 9 */ "/[{]/S",
+ /* 10 */ "/[}]/S",
+ /* 11 */ "/(<br[[:space:]]*\/?".">){2,}/S",
+ /* 12 */ "/<p>([\n]*(<br[[:space:]]*\/?".">)*)*/S",
+ /* 13 */ "/<quote>/S",
+ /* 14 */ "/<\/quote>/S"
+ );
+ $remplace1 = array(
+ /* 0 */ "\n\n$ligne_horizontale\n\n",
+ /* 1 */ "\n<br />&mdash;&nbsp;",
+ /* 2 */ "\n<br />$puce&nbsp;",
+ /* 3 */ "\n<br />",
+ /* 4 */ "\$1\n\n$debut_intertitre",
+ /* 5 */ "$fin_intertitre\n\n\$1",
+ /* 6 */ "<p>",
+ /* 7 */ "<strong class=\"spip\">",
+ /* 8 */ "</strong>",
+ /* 9 */ "<i class=\"spip\">",
+ /* 10 */ "</i>",
+ /* 11 */ "<p>",
+ /* 12 */ "<p>",
+ /* 13 */ "<blockquote class=\"spip\"><p>",
+ /* 14 */ "</blockquote><p>"
+ );
+ $letexte = preg_replace($cherche1, $remplace1, $letexte);
+ $letexte = preg_replace("@^ <br />@S", "", $letexte);
+
+ print $letexte;
+
+?>
+--EXPECT--
+<p>
diff --git a/ext/pcre/tests/bug41638.phpt b/ext/pcre/tests/bug41638.phpt
new file mode 100644
index 0000000..8c907f9
--- /dev/null
+++ b/ext/pcre/tests/bug41638.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Bug #41638 (pcre 7.0 regression)
+--FILE--
+<?php
+$str = "repeater id='loopt' dataSrc=subject colums=2";
+
+preg_match_all("/(['\"])((.*(\\\\\\1)*)*)\\1/sU",$str,$str_instead);
+print_r($str_instead);
+
+// these two are from Magnus Holmgren (extracted from a pcre-dev mailing list post)
+preg_match_all("/(['\"])((?:\\\\\\1|.)*)\\1/sU", $str, $str_instead);
+print_r($str_instead);
+
+preg_match_all("/(['\"])(.*)(?<!\\\\)\\1/sU", $str, $str_instead);
+print_r($str_instead);
+
+?>
+--EXPECT--
+Array
+(
+ [0] => Array
+ (
+ [0] => 'loopt'
+ )
+
+ [1] => Array
+ (
+ [0] => '
+ )
+
+ [2] => Array
+ (
+ [0] => loopt
+ )
+
+ [3] => Array
+ (
+ [0] => t
+ )
+
+ [4] => Array
+ (
+ [0] =>
+ )
+
+)
+Array
+(
+ [0] => Array
+ (
+ [0] => 'loopt'
+ )
+
+ [1] => Array
+ (
+ [0] => '
+ )
+
+ [2] => Array
+ (
+ [0] => loopt
+ )
+
+)
+Array
+(
+ [0] => Array
+ (
+ [0] => 'loopt'
+ )
+
+ [1] => Array
+ (
+ [0] => '
+ )
+
+ [2] => Array
+ (
+ [0] => loopt
+ )
+
+)
diff --git a/ext/pcre/tests/bug42298.phpt b/ext/pcre/tests/bug42298.phpt
new file mode 100644
index 0000000..156f356
--- /dev/null
+++ b/ext/pcre/tests/bug42298.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #42298 (pcre gives bogus results with /u)
+--FILE--
+<?php
+$str = "A\xc2\xa3BC";
+preg_match_all('/\S\S/u', $str, $m); var_dump($m);
+preg_match_all('/\S{2}/u', $str, $m); var_dump($m);
+
+$str = "A\xe2\x82\xac ";
+preg_match_all('/\W\W/u', $str, $m); var_dump($m);
+preg_match_all('/\W{2}/u', $str, $m); var_dump($m);
+
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(3) "A£"
+ [1]=>
+ string(2) "BC"
+ }
+}
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(3) "A£"
+ [1]=>
+ string(2) "BC"
+ }
+}
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(4) "€ "
+ }
+}
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(4) "€ "
+ }
+}
diff --git a/ext/pcre/tests/bug42737.phpt b/ext/pcre/tests/bug42737.phpt
new file mode 100644
index 0000000..8d9dd52
--- /dev/null
+++ b/ext/pcre/tests/bug42737.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines)
+--FILE--
+<?php
+
+$string = chr(13).chr(10);
+
+$array = preg_split('//u', $string, - 1, PREG_SPLIT_NO_EMPTY);
+
+var_dump(array_map('ord', $array));
+
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ int(13)
+ [1]=>
+ int(10)
+}
diff --git a/ext/pcre/tests/bug42945.phpt b/ext/pcre/tests/bug42945.phpt
new file mode 100644
index 0000000..c6d2b82
--- /dev/null
+++ b/ext/pcre/tests/bug42945.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Bug #42945 (preg_split() swallows part of the string)
+--FILE--
+<?php
+
+var_dump(preg_match_all('/\b/', "a'", $m, PREG_OFFSET_CAPTURE));
+var_dump($m);
+
+var_dump(preg_split('/\b/', "a'"));
+var_dump(preg_split('/\b/', "a'", -1, PREG_SPLIT_OFFSET_CAPTURE));
+var_dump(preg_split('/\b/', "a'", -1, PREG_SPLIT_NO_EMPTY));
+var_dump(preg_split('/\b/', "a'", -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_OFFSET_CAPTURE));
+
+?>
+--EXPECT--
+int(2)
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(1)
+ }
+ }
+}
+array(3) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(1) "a"
+ [2]=>
+ string(1) "'"
+}
+array(3) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(0)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(1) "'"
+ [1]=>
+ int(1)
+ }
+}
+array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "'"
+}
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "'"
+ [1]=>
+ int(1)
+ }
+}
diff --git a/ext/pcre/tests/bug44191.phpt b/ext/pcre/tests/bug44191.phpt
new file mode 100644
index 0000000..52b4490
--- /dev/null
+++ b/ext/pcre/tests/bug44191.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #44191 (preg_grep messes up array index)
+--FILE--
+<?php
+
+$array = range(1, 10);
+
+preg_grep('/asdf/', $array);
+
+while (list($x) = each($array)) {
+ print $x;
+}
+
+?>
+--EXPECT--
+0123456789
diff --git a/ext/pcre/tests/bug44214.phpt b/ext/pcre/tests/bug44214.phpt
new file mode 100644
index 0000000..90e4c86
--- /dev/null
+++ b/ext/pcre/tests/bug44214.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #44214 (crash with preg_replace_callback() and global variable)
+--FILE--
+<?php
+$string = 'aaa bbb ccc ddd eee ccc aaa bbb';
+
+$array = array();
+
+function myCallBack( $match ) {
+ global $array;
+ $array[] = $match;
+ return 'xxx';
+}
+
+var_dump(preg_replace_callback( '`a+`', 'myCallBack', $string));
+var_dump($array);
+?>
+--EXPECT--
+string(31) "xxx bbb ccc ddd eee ccc xxx bbb"
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "aaa"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(3) "aaa"
+ }
+}
diff --git a/ext/pcre/tests/bug44214_2.phpt b/ext/pcre/tests/bug44214_2.phpt
new file mode 100644
index 0000000..d78846c
--- /dev/null
+++ b/ext/pcre/tests/bug44214_2.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #44214-2 (crash with preg_replace_callback() and global variable)
+--FILE--
+<?php
+$string = 'aaa bbb ccc ddd eee ccc aaa bbb';
+
+$array = array();
+
+function myCallBack( $match ) {
+ global $array;
+ $array[] = $match[0];
+ return 'xxx';
+}
+
+var_dump(preg_replace_callback( '`a+`', 'myCallBack', $string));
+var_dump($array);
+?>
+--EXPECT--
+string(31) "xxx bbb ccc ddd eee ccc xxx bbb"
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "aaa"
+}
diff --git a/ext/pcre/tests/bug44925.phpt b/ext/pcre/tests/bug44925.phpt
new file mode 100644
index 0000000..f6e0db4
--- /dev/null
+++ b/ext/pcre/tests/bug44925.phpt
@@ -0,0 +1,107 @@
+--TEST--
+Bug #44925 (preg_grep() modifies input array)
+--FILE--
+<?php
+$str1 = 'a';
+$str2 = 'b';
+
+$array=Array("1",2,3,1.1,FALSE,NULL,Array(), $str1, &$str2);
+
+var_dump($array);
+
+var_dump(preg_grep('/do not match/',$array));
+
+$a = preg_grep('/./',$array);
+var_dump($a);
+
+$str1 = 'x';
+$str2 = 'y';
+
+var_dump($a); // check if array is still ok
+
+var_dump($array);
+
+?>
+--EXPECTF--
+array(9) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ float(1.1)
+ [4]=>
+ bool(false)
+ [5]=>
+ NULL
+ [6]=>
+ array(0) {
+ }
+ [7]=>
+ string(1) "a"
+ [8]=>
+ &string(1) "b"
+}
+
+Notice: Array to string conversion in %sbug44925.php on line 9
+array(0) {
+}
+
+Notice: Array to string conversion in %sbug44925.php on line 11
+array(7) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ float(1.1)
+ [6]=>
+ array(0) {
+ }
+ [7]=>
+ string(1) "a"
+ [8]=>
+ &string(1) "b"
+}
+array(7) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ float(1.1)
+ [6]=>
+ array(0) {
+ }
+ [7]=>
+ string(1) "a"
+ [8]=>
+ &string(1) "y"
+}
+array(9) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ float(1.1)
+ [4]=>
+ bool(false)
+ [5]=>
+ NULL
+ [6]=>
+ array(0) {
+ }
+ [7]=>
+ string(1) "a"
+ [8]=>
+ &string(1) "y"
+}
diff --git a/ext/pcre/tests/bug47229.phpt b/ext/pcre/tests/bug47229.phpt
new file mode 100644
index 0000000..96b95a2
--- /dev/null
+++ b/ext/pcre/tests/bug47229.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #47229 (preg_quote() doesn't escape -)
+--FILE--
+<?php
+
+var_dump(preg_quote('-oh really?'));
+
+// make sure there's no regression in matching
+preg_match('/[a\-c]+/', 'a---b', $m);
+var_dump($m);
+
+preg_match('/[a\-c]+/', 'a\-', $m);
+var_dump($m);
+
+preg_match("/a\-{2,}/", 'a----a', $m);
+var_dump($m);
+
+preg_match("/a\-{1,}/", 'a\----a', $m);
+var_dump($m);
+
+?>
+--EXPECTF--
+%string|unicode%(13) "\-oh really\?"
+array(1) {
+ [0]=>
+ %string|unicode%(4) "a---"
+}
+array(1) {
+ [0]=>
+ %string|unicode%(1) "a"
+}
+array(1) {
+ [0]=>
+ %string|unicode%(5) "a----"
+}
+array(0) {
+}
diff --git a/ext/pcre/tests/bug47662.phpt b/ext/pcre/tests/bug47662.phpt
new file mode 100644
index 0000000..d605674
--- /dev/null
+++ b/ext/pcre/tests/bug47662.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #47662 (support more than 127 named subpatterns)
+--FILE--
+<?php
+
+$regex = '@';
+for($bar=0; $bar<1027; $bar++) {
+ $regex .= '((?P<x'.$bar.'>))';
+}
+$regex .= 'fo+bar@';
+
+var_dump(preg_match($regex, 'foobar'));
+echo "Done!\n";
+
+?>
+--EXPECT--
+int(1)
+Done!
diff --git a/ext/pcre/tests/bug52732.phpt b/ext/pcre/tests/bug52732.phpt
new file mode 100644
index 0000000..8cfa204
--- /dev/null
+++ b/ext/pcre/tests/bug52732.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #52732 (Docs say preg_match() returns FALSE on error, but it returns int(0))
+--INI--
+pcre.backtrack_limit=1
+--FILE--
+<?php
+$ret = preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
+
+var_dump($ret);
+
+?>
+--EXPECT--
+bool(false) \ No newline at end of file
diff --git a/ext/pcre/tests/bug52971.phpt b/ext/pcre/tests/bug52971.phpt
new file mode 100644
index 0000000..5949cb2
--- /dev/null
+++ b/ext/pcre/tests/bug52971.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #52971 (PCRE-Meta-Characters not working with utf-8)
+--SKIPIF--
+<?php if ((double)PCRE_VERSION < 8.1) die('skip PCRE_VERSION >= 8.1 is required!'); ?>
+--FILE--
+<?php
+
+$message = 'Der ist ein Süßwasserpool Süsswasserpool ... verschiedene Wassersportmöglichkeiten bei ...';
+
+$pattern = '/\bwasser/iu';
+preg_match_all($pattern, $message, $match, PREG_OFFSET_CAPTURE);
+var_dump($match);
+
+$pattern = '/[^\w]wasser/iu';
+preg_match_all($pattern, $message, $match, PREG_OFFSET_CAPTURE);
+var_dump($match);
+
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(6) "Wasser"
+ [1]=>
+ int(61)
+ }
+ }
+}
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(7) " Wasser"
+ [1]=>
+ int(60)
+ }
+ }
+}
diff --git a/ext/pcre/tests/bug63055.phpt b/ext/pcre/tests/bug63055.phpt
new file mode 100644
index 0000000..16c50b5
--- /dev/null
+++ b/ext/pcre/tests/bug63055.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #63055 (Segfault in zend_gc with SF2 testsuite)
+--FILE--
+<?php
+/* the default gc root size is 10,000 */
+for ($i=0; $i<9998; $i++) {
+ $array = array();
+ $array[0] = &$array;
+ unset($array);
+}
+
+$matches = array("foo" => "bar"); /* this bucket will trigger the segfault */
+$dummy = array("dummy"); /* used to trigger gc_collect_cycles */
+$dummy[1] = &$dummy;
+
+$matches[1] = &$matches;
+$matches[2] = $dummy;
+
+preg_match_all("/(\d)+/", "foo123456bar", $matches);
+echo "okey";
+?>
+--EXPECTF--
+okey
diff --git a/ext/pcre/tests/cache_limit.phpt b/ext/pcre/tests/cache_limit.phpt
new file mode 100644
index 0000000..bfe7f1b
--- /dev/null
+++ b/ext/pcre/tests/cache_limit.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Compiled regex cache limit
+--FILE--
+<?php
+define('PREG_CACHE_SIZE', 4096+1);
+
+$re = '';
+$str = str_repeat('x', PREG_CACHE_SIZE);
+
+for ($i=0; $i < PREG_CACHE_SIZE; ++$i) {
+ $re .= '.';
+ if (!preg_match("/$re/", $str)) {
+ die('non match. error');
+ }
+}
+
+var_dump(preg_match('/./', $str)); // this one was already deleted from the cache
+var_dump(preg_match("/$re/", $str)); // but not this one
+
+echo "done\n";
+?>
+--EXPECT--
+int(1)
+int(1)
+done
diff --git a/ext/pcre/tests/delimiters.phpt b/ext/pcre/tests/delimiters.phpt
new file mode 100644
index 0000000..1826f87
--- /dev/null
+++ b/ext/pcre/tests/delimiters.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Delimiters crash test
+--FILE--
+<?php
+
+var_dump(preg_match('', ''));
+var_dump(preg_match(' ', ''));
+var_dump(preg_match('@@', ''));
+var_dump(preg_match('12', ''));
+var_dump(preg_match('<>', ''));
+var_dump(preg_match('~a', ''));
+var_dump(preg_match('@\@\@@', '@@'));
+var_dump(preg_match('//z', '@@'));
+var_dump(preg_match('{', ''));
+
+?>
+--EXPECTF--
+Warning: preg_match(): Empty regular expression in %sdelimiters.php on line 3
+bool(false)
+
+Warning: preg_match(): Empty regular expression in %sdelimiters.php on line 4
+bool(false)
+int(1)
+
+Warning: preg_match(): Delimiter must not be alphanumeric or backslash in %sdelimiters.php on line 6
+bool(false)
+int(1)
+
+Warning: preg_match(): No ending delimiter '~' found in %sdelimiters.php on line 8
+bool(false)
+int(1)
+
+Warning: preg_match(): Unknown modifier 'z' in %sdelimiters.php on line 10
+bool(false)
+
+Warning: preg_match(): No ending matching delimiter '}' found in %sdelimiters.php on line 11
+bool(false)
diff --git a/ext/pcre/tests/dollar_endonly.phpt b/ext/pcre/tests/dollar_endonly.phpt
new file mode 100644
index 0000000..96a5244
--- /dev/null
+++ b/ext/pcre/tests/dollar_endonly.phpt
@@ -0,0 +1,39 @@
+--TEST--
+D (PCRE_DOLLAR_ENDONLY) modififer
+--FILE--
+<?php
+
+var_dump(preg_match_all('/^\S+.+$/', "aeiou\n", $m));
+var_dump($m);
+
+var_dump(preg_match_all('/^\S+.+$/D', "aeiou\n", $m));
+var_dump($m);
+
+var_dump(preg_match_all('/^\S+\s$/D', "aeiou\n", $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(1)
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(5) "aeiou"
+ }
+}
+int(0)
+array(1) {
+ [0]=>
+ array(0) {
+ }
+}
+int(1)
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(6) "aeiou
+"
+ }
+}
diff --git a/ext/pcre/tests/grep.phpt b/ext/pcre/tests/grep.phpt
new file mode 100644
index 0000000..d3d9032
--- /dev/null
+++ b/ext/pcre/tests/grep.phpt
@@ -0,0 +1,23 @@
+--TEST--
+preg_grep()
+--FILE--
+<?php
+$array = array('a', '1', 'q6', 'h20');
+
+var_dump(preg_grep('/^(\d|.\d)$/', $array));
+var_dump(preg_grep('/^(\d|.\d)$/', $array, PREG_GREP_INVERT));
+
+?>
+--EXPECT--
+array(2) {
+ [1]=>
+ string(1) "1"
+ [2]=>
+ string(2) "q6"
+}
+array(2) {
+ [0]=>
+ string(1) "a"
+ [3]=>
+ string(3) "h20"
+}
diff --git a/ext/pcre/tests/grep2.phpt b/ext/pcre/tests/grep2.phpt
new file mode 100644
index 0000000..0cf8d4a
--- /dev/null
+++ b/ext/pcre/tests/grep2.phpt
@@ -0,0 +1,45 @@
+--TEST--
+preg_grep() 2nd test
+--FILE--
+<?php
+
+var_dump(preg_grep(1,array(),3,4));
+var_dump(preg_grep(1, 2));
+var_dump(preg_grep('/+/', array()));
+
+$array = array(5=>'a', 'x' => '1', 'xyz'=>'q6', 'h20');
+
+var_dump(preg_grep('@^[a-z]+@', $array));
+var_dump(preg_grep('@^[a-z]+@', $array, PREG_GREP_INVERT));
+
+ini_set('pcre.recursion_limit', 1);
+var_dump(preg_last_error() == PREG_NO_ERROR);
+var_dump(preg_grep('@^[a-z]+@', $array));
+var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
+
+?>
+--EXPECTF--
+Warning: preg_grep() expects at most 3 parameters, 4 given in %sgrep2.php on line 3
+NULL
+
+Warning: preg_grep() expects parameter 2 to be array, integer given in %sgrep2.php on line 4
+NULL
+
+Warning: preg_grep(): Compilation failed: nothing to repeat at offset 0 in %sgrep2.php on line 5
+bool(false)
+array(3) {
+ [5]=>
+ string(1) "a"
+ ["xyz"]=>
+ string(2) "q6"
+ [6]=>
+ string(3) "h20"
+}
+array(1) {
+ ["x"]=>
+ string(1) "1"
+}
+bool(true)
+array(0) {
+}
+bool(true)
diff --git a/ext/pcre/tests/invalid_utf8.phpt b/ext/pcre/tests/invalid_utf8.phpt
new file mode 100644
index 0000000..56bad83
--- /dev/null
+++ b/ext/pcre/tests/invalid_utf8.phpt
@@ -0,0 +1,22 @@
+--TEST--
+preg_replace() and invalid UTF8
+--SKIPIF--
+<?php
+if (@preg_match('/./u', '') === false) {
+ die('skip no utf8 support in PCRE library');
+}
+?>
+--FILE--
+<?php
+
+$string = urldecode("search%e4");
+$result = preg_replace("#(&\#x*)([0-9A-F]+);*#iu","$1$2;",$string);
+var_dump($result);
+var_dump(preg_last_error());
+
+echo "Done\n";
+?>
+--EXPECT--
+NULL
+int(4)
+Done
diff --git a/ext/pcre/tests/invalid_utf8_offset.phpt b/ext/pcre/tests/invalid_utf8_offset.phpt
new file mode 100644
index 0000000..50716ca
--- /dev/null
+++ b/ext/pcre/tests/invalid_utf8_offset.phpt
@@ -0,0 +1,35 @@
+--TEST--
+preg_replace() and invalid UTF8 offset
+--SKIPIF--
+<?php
+if (@preg_match('/./u', '') === false) {
+ die('skip no utf8 support in PCRE library');
+}
+?>
+--FILE--
+<?php
+
+$string = b"\xc3\xa9 uma string utf8 bem formada";
+
+var_dump(preg_match(b'~.*~u', $string, $m, 0, 1));
+var_dump($m);
+var_dump(preg_last_error() == PREG_BAD_UTF8_OFFSET_ERROR);
+
+var_dump(preg_match(b'~.*~u', $string, $m, 0, 2));
+var_dump($m);
+var_dump(preg_last_error() == PREG_NO_ERROR);
+
+echo "Done\n";
+?>
+--EXPECT--
+bool(false)
+array(0) {
+}
+bool(true)
+int(1)
+array(1) {
+ [0]=>
+ string(28) " uma string utf8 bem formada"
+}
+bool(true)
+Done
diff --git a/ext/pcre/tests/locales.phpt b/ext/pcre/tests/locales.phpt
new file mode 100644
index 0000000..a103020
--- /dev/null
+++ b/ext/pcre/tests/locales.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Localized match
+--SKIPIF--
+<?php
+
+if (!function_exists('setlocale')) die('skip: setlocale() not available');
+if (!@setlocale(LC_ALL, 'pt_PT', 'pt', 'pt_PT.ISO8859-1', 'portuguese')) die('skip pt locale not available');
+
+?>
+--FILE--
+<?php
+
+// this tests if the cache is working correctly, as the char tables
+// must be rebuilt after the locale change
+
+setlocale(LC_ALL, 'C', 'POSIX');
+var_dump(preg_match('/^\w{6}$/', 'aàáçéè'));
+
+setlocale(LC_ALL, 'pt_PT', 'pt', 'pt_PT.ISO8859-1', 'portuguese');
+var_dump(preg_match('/^\w{6}$/', 'aàáçéè'));
+
+setlocale(LC_ALL, 'C', 'POSIX');
+var_dump(preg_match('/^\w{6}$/', 'aàáçéè'));
+
+?>
+--EXPECT--
+int(0)
+int(1)
+int(0)
diff --git a/ext/pcre/tests/match_flags.phpt b/ext/pcre/tests/match_flags.phpt
new file mode 100644
index 0000000..ddd36bf
--- /dev/null
+++ b/ext/pcre/tests/match_flags.phpt
@@ -0,0 +1,127 @@
+--TEST--
+preg_match_all() flags
+--FILE--
+<?php
+
+var_dump(preg_match_all('/(.)x/', 'zxax', $match, PREG_PATTERN_ORDER));
+var_dump($match);
+
+var_dump(preg_match_all('/(.)x/', 'zxyx', $match, PREG_SET_ORDER));
+var_dump($match);
+
+var_dump(preg_match_all('/(.)x/', 'zxyx', $match, PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+var_dump(preg_match_all('/(.)x/', 'zxyx', $match, PREG_SET_ORDER | PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+?>
+--EXPECT--
+int(2)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "zx"
+ [1]=>
+ string(2) "ax"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "z"
+ [1]=>
+ string(1) "a"
+ }
+}
+int(2)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "zx"
+ [1]=>
+ string(1) "z"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(2) "yx"
+ [1]=>
+ string(1) "y"
+ }
+}
+int(2)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "zx"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(2) "yx"
+ [1]=>
+ int(2)
+ }
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "z"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "y"
+ [1]=>
+ int(2)
+ }
+ }
+}
+int(2)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "zx"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "z"
+ [1]=>
+ int(0)
+ }
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "yx"
+ [1]=>
+ int(2)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "y"
+ [1]=>
+ int(2)
+ }
+ }
+}
diff --git a/ext/pcre/tests/match_flags2.phpt b/ext/pcre/tests/match_flags2.phpt
new file mode 100644
index 0000000..f703091
--- /dev/null
+++ b/ext/pcre/tests/match_flags2.phpt
@@ -0,0 +1,95 @@
+--TEST--
+preg_match() flags
+--FILE--
+<?php
+
+var_dump(preg_match('/x(.)/', 'fjszxax', $match, PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+var_dump(preg_match('/(.)x/', 'fjszxax', $match, PREG_OFFSET_CAPTURE, 4));
+var_dump($match);
+
+var_dump(preg_match('/(?P<capt1>.)(x)(?P<letsmix>\S+)/', 'fjszxax', $match, PREG_OFFSET_CAPTURE));
+var_dump($match);
+
+?>
+--EXPECT--
+int(1)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "xa"
+ [1]=>
+ int(4)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(5)
+ }
+}
+int(1)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(2) "ax"
+ [1]=>
+ int(5)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(5)
+ }
+}
+int(1)
+array(6) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(4) "zxax"
+ [1]=>
+ int(3)
+ }
+ ["capt1"]=>
+ array(2) {
+ [0]=>
+ string(1) "z"
+ [1]=>
+ int(3)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "z"
+ [1]=>
+ int(3)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ int(4)
+ }
+ ["letsmix"]=>
+ array(2) {
+ [0]=>
+ string(2) "ax"
+ [1]=>
+ int(5)
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ string(2) "ax"
+ [1]=>
+ int(5)
+ }
+}
diff --git a/ext/pcre/tests/match_flags3.phpt b/ext/pcre/tests/match_flags3.phpt
new file mode 100644
index 0000000..f22205e
--- /dev/null
+++ b/ext/pcre/tests/match_flags3.phpt
@@ -0,0 +1,46 @@
+--TEST--
+preg_match() flags 3
+--FILE--
+<?php
+
+var_dump(preg_match('', '', $match, 0xfff));
+
+var_dump(preg_match('/\d+/', '123 456 789 012', $match, 0, -8));
+var_dump($match);
+
+var_dump(preg_match('/\d+/', '123 456 789 012', $match, 0, -500));
+var_dump($match);
+
+var_dump(preg_match_all('/\d+/', '123 456 789 012', $match, 0, -8));
+var_dump($match);
+
+var_dump(preg_match('/(?P<3>)/', ''));
+
+?>
+--EXPECTF--
+
+Warning: preg_match(): Empty regular expression in %smatch_flags3.php on line 3
+bool(false)
+int(1)
+array(1) {
+ [0]=>
+ string(3) "789"
+}
+int(1)
+array(1) {
+ [0]=>
+ string(3) "123"
+}
+int(2)
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(3) "789"
+ [1]=>
+ string(3) "012"
+ }
+}
+
+Warning: preg_match(): Numeric named subpatterns are not allowed in %smatch_flags3.php on line 14
+bool(false)
diff --git a/ext/pcre/tests/multiline.phpt b/ext/pcre/tests/multiline.phpt
new file mode 100644
index 0000000..3568009
--- /dev/null
+++ b/ext/pcre/tests/multiline.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Multi-line match
+--FILE--
+<?php
+
+var_dump(preg_match_all('/^.{2,3}$/', "aei\nou", $dummy));
+var_dump(preg_match_all('/^.{2,3}$/', "aei\nou\n", $dummy));
+var_dump(preg_match_all('/^.{2,3}$/m', "aei\nou", $dummy));
+var_dump(preg_match_all('/^.{2,3}$/m', "aei\nou\n", $dummy));
+
+echo "done\n";
+?>
+--EXPECT--
+int(0)
+int(0)
+int(2)
+int(2)
+done
diff --git a/ext/pcre/tests/null_bytes.phpt b/ext/pcre/tests/null_bytes.phpt
new file mode 100644
index 0000000..9a3f433
--- /dev/null
+++ b/ext/pcre/tests/null_bytes.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Zero byte test
+--FILE--
+<?php
+
+preg_match("\0//i", "");
+preg_match("/\0/i", "");
+preg_match("//\0i", "");
+preg_match("//i\0", "");
+preg_match("/\\\0/i", "");
+
+preg_match("\0[]i", "");
+preg_match("[\0]i", "");
+preg_match("[]\0i", "");
+preg_match("[]i\0", "");
+preg_match("[\\\0]i", "");
+
+preg_replace("/foo/e\0/i", "echo('Eek');", "");
+
+?>
+--EXPECTF--
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 3
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 4
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 5
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 6
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 7
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 9
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 10
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 11
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 12
+
+Warning: preg_match(): Null byte in regex in %snull_bytes.php on line 13
+
+Warning: preg_replace(): Null byte in regex in %snull_bytes.php on line 15
diff --git a/ext/pcre/tests/pcre.constants.phpt b/ext/pcre/tests/pcre.constants.phpt
new file mode 100644
index 0000000..0b10330
--- /dev/null
+++ b/ext/pcre/tests/pcre.constants.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test for pre-defined pcre constants
+--FILE--
+<?php
+
+echo "PCRE constants test\n";
+
+echo "PREG_PATTERN_ORDER= ", PREG_PATTERN_ORDER, "\n";
+echo "PREG_OFFSET_CAPTURE= ", PREG_OFFSET_CAPTURE, "\n";
+echo "PREG_SPLIT_NO_EMPTY= ", PREG_SPLIT_NO_EMPTY, "\n";
+echo "PREG_SPLIT_DELIM_CAPTURE= ", PREG_SPLIT_DELIM_CAPTURE, "\n";
+echo "PREG_SPLIT_OFFSET_CAPTURE= ", PREG_SPLIT_OFFSET_CAPTURE, "\n";
+echo "PREG_GREP_INVERT= ", PREG_GREP_INVERT, "\n";
+echo "PREG_NO_ERROR= ", PREG_NO_ERROR, "\n";
+echo "PREG_INTERNAL_ERROR= ", PREG_INTERNAL_ERROR, "\n";
+echo "PREG_BACKTRACK_LIMIT_ERROR= ", PREG_BACKTRACK_LIMIT_ERROR, "\n";
+echo "PREG_RECURSION_LIMIT_ERROR= ", PREG_RECURSION_LIMIT_ERROR, "\n";
+echo "PREG_BAD_UTF8_ERROR= ", PREG_BAD_UTF8_ERROR, "\n";
+
+?>
+===Done===
+--EXPECT--
+PCRE constants test
+PREG_PATTERN_ORDER= 1
+PREG_OFFSET_CAPTURE= 256
+PREG_SPLIT_NO_EMPTY= 1
+PREG_SPLIT_DELIM_CAPTURE= 2
+PREG_SPLIT_OFFSET_CAPTURE= 4
+PREG_GREP_INVERT= 1
+PREG_NO_ERROR= 0
+PREG_INTERNAL_ERROR= 1
+PREG_BACKTRACK_LIMIT_ERROR= 2
+PREG_RECURSION_LIMIT_ERROR= 3
+PREG_BAD_UTF8_ERROR= 4
+===Done=== \ No newline at end of file
diff --git a/ext/pcre/tests/pcre_anchored.phpt b/ext/pcre/tests/pcre_anchored.phpt
new file mode 100644
index 0000000..a609fdb
--- /dev/null
+++ b/ext/pcre/tests/pcre_anchored.phpt
@@ -0,0 +1,28 @@
+--TEST--
+A (PCRE_ANCHORED) modififer
+--SKIPIF--
+<?php
+if (@preg_match_all('/\p{N}/', '0123456789', $dummy) === false) {
+ die("skip no support for \p support PCRE library");
+}
+?>
+--FILE--
+<?php
+
+var_dump(preg_match('/\PN+/', '123abc', $m));
+var_dump($m);
+
+var_dump(preg_match('/\P{N}+/A', '123abc'));
+var_dump(preg_match('/^\P{N}+/', '123abc'));
+var_dump(preg_match('/^\P{N}+/A', '123abc'));
+
+?>
+--EXPECT--
+int(1)
+array(1) {
+ [0]=>
+ string(3) "abc"
+}
+int(0)
+int(0)
+int(0)
diff --git a/ext/pcre/tests/pcre_count.phpt b/ext/pcre/tests/pcre_count.phpt
new file mode 100644
index 0000000..1239d48
--- /dev/null
+++ b/ext/pcre/tests/pcre_count.phpt
@@ -0,0 +1,40 @@
+--TEST--
+preg_replace() fifth parameter - count
+--FILE--
+<?php
+$regex = '/(([0-9a-z]+)-([0-9]+))-(([0-9]+)-([0-9]+))/';
+
+$string= '1-2-3-4 a-2-3-4 1-a-3-4 1-2-a-4 1-2-3-a a-a-a-a 4-3-2-1 100-200-300-400-500-600-700-800';
+$count = 0;
+var_dump(preg_replace($regex, 'xxxx', $string, -1, $count));
+var_dump($count);
+//////////////////////////////////////////////////////
+
+$regex = '/([a-z]+)/';
+
+$string= 'Here must only number like 42 and 13 appear';
+var_dump(preg_replace($regex, 'xxxx', $string, -1, $count));
+var_dump($count);
+
+////////////////////////////////////////////////////////
+$regex = '~((V(I|1)(4|A)GR(4|A))|(V(I|1)C(0|O)D(I|1)(N|\/\\\/)))~i';
+
+$string= 'Viagra V14GR4 Vicodin V1C0D1/\/ v1c0d1/|/';
+var_dump(preg_replace($regex, '...', $string, -1, $count));
+var_dump($count);
+////////////////////////////////////////////////////////
+$regex = '~((V(I|1)(4|A)GR(4|A))|(V(I|1)C(0|O)D(I|1)(N|\/\\\/)))~i';
+$count = NULL;
+$string= 'Viagra V14GR4 Vicodin V1C0D1/\/ v1c0d1/|/';
+var_dump(preg_replace($regex, '...', $string, -1));
+var_dump($count);
+?>
+--EXPECT--
+string(56) "xxxx xxxx 1-a-3-4 1-2-a-4 1-2-3-a a-a-a-a xxxx xxxx-xxxx"
+int(5)
+string(41) "Hxxxx xxxx xxxx xxxx xxxx 42 xxxx 13 xxxx"
+int(7)
+string(25) "... ... ... ... v1c0d1/|/"
+int(4)
+string(25) "... ... ... ... v1c0d1/|/"
+NULL
diff --git a/ext/pcre/tests/pcre_extended.phpt b/ext/pcre/tests/pcre_extended.phpt
new file mode 100644
index 0000000..6c4b20e
--- /dev/null
+++ b/ext/pcre/tests/pcre_extended.phpt
@@ -0,0 +1,29 @@
+--TEST--
+x (PCRE_EXTENDED) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/a e i o u/', 'aeiou', $m));
+var_dump($m);
+
+var_dump(preg_match('/a e i o u/x', 'aeiou', $m));
+var_dump($m);
+
+var_dump(preg_match("/a e\ni\to\ru/x", 'aeiou', $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(0)
+array(0) {
+}
+int(1)
+array(1) {
+ [0]=>
+ string(5) "aeiou"
+}
+int(1)
+array(1) {
+ [0]=>
+ string(5) "aeiou"
+}
diff --git a/ext/pcre/tests/pcre_extra.phpt b/ext/pcre/tests/pcre_extra.phpt
new file mode 100644
index 0000000..2bee408
--- /dev/null
+++ b/ext/pcre/tests/pcre_extra.phpt
@@ -0,0 +1,14 @@
+--TEST--
+X (PCRE_EXTRA) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/\y/', '\y'));
+var_dump(preg_match('/\y/X', '\y'));
+
+?>
+--EXPECTF--
+int(1)
+
+Warning: preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in %spcre_extra.php on line 4
+bool(false)
diff --git a/ext/pcre/tests/preg_filter.phpt b/ext/pcre/tests/preg_filter.phpt
new file mode 100644
index 0000000..6cd9802
--- /dev/null
+++ b/ext/pcre/tests/preg_filter.phpt
@@ -0,0 +1,29 @@
+--TEST--
+preg_filter()
+--FILE--
+<?php
+
+$subject = array('1', 'a', '2', 'b', '3', 'A', 'B', '4');
+$pattern = array('/\d/', '/[a-z]/', '/[1a]/');
+$replace = array('A:$0', 'B:$0', 'C:$0');
+
+var_dump(preg_filter($pattern, $replace, $subject));
+
+?>
+===DONE===
+--EXPECT--
+array(6) {
+ [0]=>
+ string(5) "A:C:1"
+ [1]=>
+ string(5) "B:C:a"
+ [2]=>
+ string(3) "A:2"
+ [3]=>
+ string(3) "B:b"
+ [4]=>
+ string(3) "A:3"
+ [7]=>
+ string(3) "A:4"
+}
+===DONE===
diff --git a/ext/pcre/tests/preg_grep_basic.phpt b/ext/pcre/tests/preg_grep_basic.phpt
new file mode 100644
index 0000000..fe9d7ce
--- /dev/null
+++ b/ext/pcre/tests/preg_grep_basic.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test preg_grep() function : basic functionality
+--FILE--
+<?php
+/*
+* proto array preg_grep(string regex, array input [, int flags])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+$array = array('HTTP://WWW.EXAMPLE.COM', '/index.html', '/info/stat/', 'http://test.uk.com/index/html', '/display/dept.php');
+var_dump($array);
+var_dump(preg_grep('@^HTTP(.*?)\w{2,}$@i', $array)); //finds a string starting with http (regardless of case) (matches two)
+var_dump(preg_grep('@(/\w+\.*/*)+@', $array)); //finds / followed by one or more of a-z, A-Z and 0-9, followed by zero or more . followed by zero or more / all more than once. (matches all)
+var_dump(preg_grep('@^http://[^w]{3}.*$@i', $array)); //finds http:// (at the beginning of a string) not followed by 3 characters that aren't w's then anything to the end of the sttring (matches one)
+var_dump(preg_grep('@.*?\.co\.uk$@i', $array)); //finds any address ending in .co.uk (matches none)
+var_dump(preg_grep('@^HTTP(.*?)\w{2,}$@i', $array, PREG_GREP_INVERT)); //same as first example but the array created contains everything that is NOT matched but the regex (matches three)
+
+?>
+--EXPECT--
+array(5) {
+ [0]=>
+ string(22) "HTTP://WWW.EXAMPLE.COM"
+ [1]=>
+ string(11) "/index.html"
+ [2]=>
+ string(11) "/info/stat/"
+ [3]=>
+ string(29) "http://test.uk.com/index/html"
+ [4]=>
+ string(17) "/display/dept.php"
+}
+array(2) {
+ [0]=>
+ string(22) "HTTP://WWW.EXAMPLE.COM"
+ [3]=>
+ string(29) "http://test.uk.com/index/html"
+}
+array(5) {
+ [0]=>
+ string(22) "HTTP://WWW.EXAMPLE.COM"
+ [1]=>
+ string(11) "/index.html"
+ [2]=>
+ string(11) "/info/stat/"
+ [3]=>
+ string(29) "http://test.uk.com/index/html"
+ [4]=>
+ string(17) "/display/dept.php"
+}
+array(1) {
+ [3]=>
+ string(29) "http://test.uk.com/index/html"
+}
+array(0) {
+}
+array(3) {
+ [1]=>
+ string(11) "/index.html"
+ [2]=>
+ string(11) "/info/stat/"
+ [4]=>
+ string(17) "/display/dept.php"
+}
diff --git a/ext/pcre/tests/preg_grep_error.phpt b/ext/pcre/tests/preg_grep_error.phpt
new file mode 100644
index 0000000..f2afdb9
--- /dev/null
+++ b/ext/pcre/tests/preg_grep_error.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test preg_grep() function : error conditions - wrong numbers of parameters
+--FILE--
+<?php
+/*
+* proto array preg_grep(string regex, array input [, int flags])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "*** Testing preg_grep() : error conditions ***\n";
+// Zero arguments
+echo "\n-- Testing preg_grep() function with Zero arguments --\n";
+var_dump(preg_grep());
+//Test preg_grep with one more than the expected number of arguments
+echo "\n-- Testing preg_grep() function with more than expected no. of arguments --\n";
+$regex = '/\d/';
+$input = array(1, 2);
+$flags = 0;
+$extra_arg = 10;
+var_dump(preg_grep($regex, $input, $flags, $extra_arg));
+// Testing preg_grep withone less than the expected number of arguments
+echo "\n-- Testing preg_grep() function with less than expected no. of arguments --\n";
+$regex = 'string_val';
+var_dump(preg_grep($regex));
+echo "Done"
+?>
+--EXPECTF--
+*** Testing preg_grep() : error conditions ***
+
+-- Testing preg_grep() function with Zero arguments --
+
+Warning: preg_grep() expects at least 2 parameters, 0 given in %spreg_grep_error.php on line %d
+NULL
+
+-- Testing preg_grep() function with more than expected no. of arguments --
+
+Warning: preg_grep() expects at most 3 parameters, 4 given in %spreg_grep_error.php on line %d
+NULL
+
+-- Testing preg_grep() function with less than expected no. of arguments --
+
+Warning: preg_grep() expects at least 2 parameters, 1 given in %spreg_grep_error.php on line %d
+NULL
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/preg_grep_error1.phpt b/ext/pcre/tests/preg_grep_error1.phpt
new file mode 100644
index 0000000..29dfc5a
--- /dev/null
+++ b/ext/pcre/tests/preg_grep_error1.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Test preg_grep() function : error conditions - bad regular expressions
+--FILE--
+<?php
+/*
+* proto array preg_grep(string regex, array input [, int flags])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_grep reacts to being passed bad regexes
+*/
+echo "*** Testing preg_grep() : error conditions ***\n";
+$values = array('abcdef', //Regex without delimeter
+'/[a-zA-Z]', //Regex without closing delimeter
+'[a-zA-Z]/', //Regex without opening delimeter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
+);
+$array = array(123, 'abc', 'test');
+foreach($values as $value) {
+ print "\nArg value is $value\n";
+ var_dump(preg_grep($value, $array));
+}
+$value = new stdclass(); //Object
+var_dump(preg_grep($value, $array));
+echo "Done"
+?>
+--EXPECTF--
+
+*** Testing preg_grep() : error conditions ***
+
+Arg value is abcdef
+
+Warning: preg_grep(): Delimiter must not be alphanumeric or backslash in %spreg_grep_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d
+bool(false)
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d
+bool(false)
+
+Arg value is Array
+
+Warning: preg_grep() expects parameter 1 to be string, array given in %spreg_grep_error1.php on line %d
+NULL
+
+Arg value is /[a-zA-Z]/
+array(2) {
+ [1]=>
+ string(3) "abc"
+ [2]=>
+ string(4) "test"
+}
+
+Warning: preg_grep() expects parameter 1 to be string, object given in %spreg_grep_error1.php on line %d
+NULL
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/preg_grep_error2.phpt b/ext/pcre/tests/preg_grep_error2.phpt
new file mode 100644
index 0000000..aa4dae9
--- /dev/null
+++ b/ext/pcre/tests/preg_grep_error2.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test preg_grep() function : error conditions - wrong arg types
+--FILE--
+<?php
+/*
+* proto array preg_grep(string regex, array input [, int flags])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_grep reacts to being passed the wrong type of input argument
+*/
+echo "*** Testing preg_grep() : error conditions ***\n";
+$regex = '/[a-zA-Z]/';
+$input = array('this is a string', array('this is', 'a subarray'),);
+foreach($input as $value) {
+ print "\nArg value is: $value\n";
+ var_dump(preg_grep($regex, $value));
+}
+$value = new stdclass(); //Object
+var_dump(preg_grep($regex, $value));
+echo "Done";
+?>
+--EXPECTF--
+*** Testing preg_grep() : error conditions ***
+
+Arg value is: this is a string
+
+Warning: preg_grep() expects parameter 2 to be array, string given in %spreg_grep_error2.php on line %d
+NULL
+
+Arg value is: Array
+array(2) {
+ [0]=>
+ string(7) "this is"
+ [1]=>
+ string(10) "a subarray"
+}
+
+Warning: preg_grep() expects parameter 2 to be array, object given in %spreg_grep_error2.php on line %d
+NULL
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/preg_last_error_error.phpt b/ext/pcre/tests/preg_last_error_error.phpt
new file mode 100644
index 0000000..c75e2f8
--- /dev/null
+++ b/ext/pcre/tests/preg_last_error_error.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test preg_grep() function : error conditions - wrong numbers of parameters
+--FILE--
+<?php
+
+/* Prototype : int preg_last_error ( void )
+ * Description: Returns the error code of the last PCRE regex execution
+ * Source code: ext/pcre/php_pcre.c
+ */
+
+/*
+ * Pass an incorrect number of arguments to preg_last_error() to test behaviour
+ */
+
+echo "*** Testing preg_last_error() : error conditions ***\n";
+
+// Test preg_last_error with one more than the expected number of arguments
+echo "\n-- Testing preg_last_error() function with more than expected no. of arguments --\n";
+$extra_arg = 10;
+var_dump( preg_last_error($extra_arg) );
+?>
+===Done===
+--EXPECTF--
+*** Testing preg_last_error() : error conditions ***
+
+-- Testing preg_last_error() function with more than expected no. of arguments --
+
+Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+===Done=== \ No newline at end of file
diff --git a/ext/pcre/tests/preg_match_all_basic.phpt b/ext/pcre/tests/preg_match_all_basic.phpt
new file mode 100644
index 0000000..20c4a96
--- /dev/null
+++ b/ext/pcre/tests/preg_match_all_basic.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Test preg_match_all() function : basic functionality
+--FILE--
+<?php
+/*
+* proto int preg_match_all(string pattern, string subject, [array subpatterns [, int flags [, int offset]]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+$string = 'Hello, world! This is a test. This is another test. \[4]. 34534 string.';
+var_dump(preg_match_all('/[0-35-9]/', $string, $match1, PREG_OFFSET_CAPTURE|PREG_PATTERN_ORDER, -10)); //finds any digit that's not 4 10 digits from the end(1 match)
+var_dump($match1);
+var_dump(preg_match_all('/[tT]his is a(.*?)\./', $string, $match2, PREG_SET_ORDER)); //finds "This is a test." and "This is another test." (non-greedy) (2 matches)
+var_dump($match2);
+var_dump(preg_match_all('@\. \\\(.*).@', $string, $match3, PREG_PATTERN_ORDER)); //finds ".\ [...]" and everything else to the end of the string. (greedy) (1 match)
+var_dump($match3);
+var_dump(preg_match_all('/\d{2}$/', $string, $match4)); //tries to find 2 digits at the end of a string (0 matches)
+var_dump($match4);
+var_dump(preg_match_all('/(This is a ){2}(.*)\stest/', $string, $match5)); //tries to find "This is aThis is a [...] test" (0 matches)
+var_dump($match5);
+
+// Test not passing in a subpatterns array.
+var_dump(preg_match_all('/test/', $string));
+var_dump(preg_match_all('/this isn\'t in the string/', $string));
+var_dump(preg_match_all('/world/', $string));
+var_dump(preg_match_all('/[0-9]/', $string));
+?>
+--EXPECTF--
+int(1)
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "3"
+ [1]=>
+ int(61)
+ }
+ }
+}
+int(2)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(15) "This is a test."
+ [1]=>
+ string(5) " test"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(21) "This is another test."
+ [1]=>
+ string(11) "nother test"
+ }
+}
+int(1)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(21) ". \[4]. 34534 string."
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(17) "[4]. 34534 string"
+ }
+}
+int(0)
+array(1) {
+ [0]=>
+ array(0) {
+ }
+}
+int(0)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+int(2)
+int(0)
+int(1)
+int(6)
diff --git a/ext/pcre/tests/preg_match_all_edit_basic.phpt b/ext/pcre/tests/preg_match_all_edit_basic.phpt
new file mode 100644
index 0000000..9edcf73
--- /dev/null
+++ b/ext/pcre/tests/preg_match_all_edit_basic.phpt
@@ -0,0 +1,89 @@
+--TEST--
+Test preg_match_all() function : basic functionality
+--FILE--
+<?php
+/* Prototype : proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
+ * Description: Perform a Perl-style global regular expression match
+ * Source code: ext/pcre/php_pcre.c
+ * Alias to functions:
+*/
+
+$string = 'Hello, world! This is a test. This is another test. \[4]. 34534 string.';
+
+var_dump(preg_match_all('/[0-35-9]/', $string, $match1, PREG_OFFSET_CAPTURE|PREG_PATTERN_ORDER, -10)); //finds any digit that's not 4 10 digits from the end(1 match)
+var_dump($match1);
+
+var_dump(preg_match_all('/[tT]his is a(.*?)\./', $string, $match2, PREG_SET_ORDER)); //finds "This is a test." and "This is another test." (non-greedy) (2 matches)
+var_dump($match2);
+
+var_dump(preg_match_all('@\. \\\(.*).@', $string, $match3, PREG_PATTERN_ORDER)); //finds ".\ [...]" and everything else to the end of the string. (greedy) (1 match)
+var_dump($match3);
+
+var_dump(preg_match_all('/\d{2}$/', $string, $match4)); //tries to find 2 digits at the end of a string (0 matches)
+var_dump($match4);
+
+var_dump(preg_match_all('/(This is a ){2}(.*)\stest/', $string, $match5)); //tries to find "This is aThis is a [...] test" (0 matches)
+var_dump($match5);
+?>
+--EXPECTF--
+int(1)
+array(1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "3"
+ [1]=>
+ int(61)
+ }
+ }
+}
+int(2)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(15) "This is a test."
+ [1]=>
+ string(5) " test"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(21) "This is another test."
+ [1]=>
+ string(11) "nother test"
+ }
+}
+int(1)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(21) ". \[4]. 34534 string."
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(17) "[4]. 34534 string"
+ }
+}
+int(0)
+array(1) {
+ [0]=>
+ array(0) {
+ }
+}
+int(0)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
diff --git a/ext/pcre/tests/preg_match_all_error.phpt b/ext/pcre/tests/preg_match_all_error.phpt
new file mode 100644
index 0000000..f6e8928
--- /dev/null
+++ b/ext/pcre/tests/preg_match_all_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test preg_match_all() function : error conditions - incorrect number of parameters
+--FILE--
+<?php
+/*
+* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "*** Testing preg_match_all() : error conditions ***\n";
+// Zero arguments
+echo "\n-- Testing preg_match_all() function with Zero arguments --\n";
+var_dump(preg_match_all());
+//Test preg_match_all with one more than the expected number of arguments
+echo "\n-- Testing preg_match_all() function with more than expected no. of arguments --\n";
+$pattern = '/\w/';
+$subject = 'string_val';
+$flags = PREG_OFFSET_CAPTURE;
+$offset = 10;
+$extra_arg = 10;
+var_dump(preg_match_all($pattern, $subject, $matches, $flags, $offset, $extra_arg));
+// Testing preg_match_all withone less than the expected number of arguments
+echo "\n-- Testing preg_match_all() function with less than expected no. of arguments --\n";
+$pattern = '/\w/';
+var_dump(preg_match_all($pattern));
+echo "Done"
+?>
+--EXPECTF--
+*** Testing preg_match_all() : error conditions ***
+
+-- Testing preg_match_all() function with Zero arguments --
+
+Warning: preg_match_all() expects at least 2 parameters, 0 given in %spreg_match_all_error.php on line %d
+bool(false)
+
+-- Testing preg_match_all() function with more than expected no. of arguments --
+
+Warning: preg_match_all() expects at most 5 parameters, 6 given in %spreg_match_all_error.php on line %d
+bool(false)
+
+-- Testing preg_match_all() function with less than expected no. of arguments --
+
+Warning: preg_match_all() expects at least 2 parameters, 1 given in %spreg_match_all_error.php on line %d
+bool(false)
+Done
diff --git a/ext/pcre/tests/preg_match_all_error1.phpt b/ext/pcre/tests/preg_match_all_error1.phpt
new file mode 100644
index 0000000..a3cb684
--- /dev/null
+++ b/ext/pcre/tests/preg_match_all_error1.phpt
@@ -0,0 +1,81 @@
+--TEST--
+Test preg_match_all() function : error conditions - bad regular expressions
+--FILE--
+<?php
+/*
+* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_match_all reacts to being passed the wrong type of regex argument
+*/
+echo "*** Testing preg_match_all() : error conditions ***\n";
+$regex_array = array('abcdef', //Regex without delimeter
+'/[a-zA-Z]', //Regex without closing delimeter
+'[a-zA-Z]/', //Regex without opening delimeter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
+);
+$subject = 'test';
+foreach($regex_array as $regex_value) {
+ print "\nArg value is $regex_value\n";
+ var_dump(preg_match_all($regex_value, $subject, $matches1));
+ var_dump($matches1);
+}
+$regex_value = new stdclass(); //Object
+var_dump(preg_match_all($regex_value, $subject, $matches));
+var_dump($matches);
+?>
+--EXPECTF--
+*** Testing preg_match_all() : error conditions ***
+
+Arg value is abcdef
+
+Warning: preg_match_all(): Delimiter must not be alphanumeric or backslash in %spreg_match_all_error1.php on line %d
+bool(false)
+NULL
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_match_all(): No ending delimiter '/' found in %spreg_match_all_error1.php on line %d
+bool(false)
+NULL
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_match_all(): Unknown modifier '/' in %spreg_match_all_error1.php on line %d
+bool(false)
+NULL
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_match_all(): Unknown modifier 'F' in %spreg_match_all_error1.php on line %d
+bool(false)
+NULL
+
+Arg value is Array
+
+Warning: preg_match_all() expects parameter 1 to be string, array given in %spreg_match_all_error1.php on line %d
+bool(false)
+NULL
+
+Arg value is /[a-zA-Z]/
+int(4)
+array(1) {
+ [0]=>
+ array(4) {
+ [0]=>
+ string(1) "t"
+ [1]=>
+ string(1) "e"
+ [2]=>
+ string(1) "s"
+ [3]=>
+ string(1) "t"
+ }
+}
+
+Warning: preg_match_all() expects parameter 1 to be string, object given in %spreg_match_all_error1.php on line %d
+bool(false)
+NULL
diff --git a/ext/pcre/tests/preg_match_all_error2.phpt b/ext/pcre/tests/preg_match_all_error2.phpt
new file mode 100644
index 0000000..1c55cce
--- /dev/null
+++ b/ext/pcre/tests/preg_match_all_error2.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test preg_match_all() function : error conditions - wrong arg types
+--FILE--
+<?php
+/*
+* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_match_all reacts to being passed the wrong type of input argument
+*/
+echo "*** Testing preg_match_all() : error conditions ***\n";
+$regex = '/[a-zA-Z]/';
+$value = new stdclass(); //Object
+var_dump(preg_match_all($regex, $value, $matches));
+var_dump($matches);
+$input = array(array('this is', 'a subarray'), 'test',);
+foreach($input as $value) {
+ print "\nArg value is: $value\n";
+ var_dump(preg_match_all($regex, $value, $matches));
+ var_dump($matches);
+}
+echo "Done";
+?>
+--EXPECTF--
+*** Testing preg_match_all() : error conditions ***
+
+Warning: preg_match_all() expects parameter 2 to be string, object given in %spreg_match_all_error2.php on line %d
+bool(false)
+NULL
+
+Arg value is: Array
+
+Warning: preg_match_all() expects parameter 2 to be string, array given in %spreg_match_all_error2.php on line %d
+bool(false)
+NULL
+
+Arg value is: test
+int(4)
+array(1) {
+ [0]=>
+ array(4) {
+ [0]=>
+ string(1) "t"
+ [1]=>
+ string(1) "e"
+ [2]=>
+ string(1) "s"
+ [3]=>
+ string(1) "t"
+ }
+}
+Done
diff --git a/ext/pcre/tests/preg_match_all_error3.phpt b/ext/pcre/tests/preg_match_all_error3.phpt
new file mode 100644
index 0000000..547ff03
--- /dev/null
+++ b/ext/pcre/tests/preg_match_all_error3.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Test preg_match_all() function : error conditions
+--FILE--
+<?php
+/*
+* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+/*
+* Testing how preg_match_all reacts to being passed the wrong type of subpatterns array argument
+*/
+echo "*** Testing preg_match_all() : error conditions ***\n";
+$regex = '/[a-z]/';
+$subject = 'string';
+var_dump(preg_match_all($regex, $subject, 'test'));
+echo "Done";
+?>
+--EXPECTF--
+
+Fatal error: Only variables can be passed by reference in %spreg_match_all_error3.php on line %d
diff --git a/ext/pcre/tests/preg_match_basic.phpt b/ext/pcre/tests/preg_match_basic.phpt
new file mode 100644
index 0000000..ddf54a0
--- /dev/null
+++ b/ext/pcre/tests/preg_match_basic.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test preg_match() function : basic functionality
+--FILE--
+<?php
+/*
+ * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
+ * Function is implemented in ext/pcre/php_pcre.c
+*/
+$string = 'Hello, world. [*], this is \ a string';
+var_dump(preg_match('/^[hH]ello,\s/', $string, $match1)); //finds "Hello, "
+var_dump($match1);
+var_dump(preg_match('/l^o,\s\w{5}/', $string, $match2, PREG_OFFSET_CAPTURE)); // tries to find "lo, world" at start of string
+var_dump($match2);
+var_dump(preg_match('/\[\*\],\s(.*)/', $string, $match3)); //finds "[*], this is \ a string";
+var_dump($match3);
+var_dump(preg_match('@\w{4}\s\w{2}\s\\\(?:\s.*)@', $string, $match4, PREG_OFFSET_CAPTURE, 14)); //finds "this is \ a string" (with non-capturing parentheses)
+var_dump($match4);
+var_dump(preg_match('/hello world/', $string, $match5)); //tries to find "hello world" (should be Hello, world)
+var_dump($match5);
+?>
+
+--EXPECTF--
+
+int(1)
+array(1) {
+ [0]=>
+ string(7) "Hello, "
+}
+int(0)
+array(0) {
+}
+int(1)
+array(2) {
+ [0]=>
+ string(23) "[*], this is \ a string"
+ [1]=>
+ string(18) "this is \ a string"
+}
+int(1)
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(18) "this is \ a string"
+ [1]=>
+ int(19)
+ }
+}
+int(0)
+array(0) {
+}
+
diff --git a/ext/pcre/tests/preg_match_basic_002.phpt b/ext/pcre/tests/preg_match_basic_002.phpt
new file mode 100644
index 0000000..977a67e
--- /dev/null
+++ b/ext/pcre/tests/preg_match_basic_002.phpt
@@ -0,0 +1,23 @@
+--TEST--
+preg_match() single line match with multi-line input
+--FILE--
+<?php
+/* Prototype : int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags [, int $offset ]]] )
+ * Description: Perform a regular expression match
+ * Source code: ext/pcre/php_pcre.c
+ */
+
+$string = "My\nName\nIs\nStrange";
+preg_match("/M(.*)/", $string, $matches);
+
+var_dump($matches);
+?>
+===Done===
+--EXPECTF--
+array(2) {
+ [0]=>
+ string(2) "My"
+ [1]=>
+ string(1) "y"
+}
+===Done=== \ No newline at end of file
diff --git a/ext/pcre/tests/preg_match_basic_edit.phpt b/ext/pcre/tests/preg_match_basic_edit.phpt
new file mode 100644
index 0000000..bd469d3
--- /dev/null
+++ b/ext/pcre/tests/preg_match_basic_edit.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test preg_match() function : basic functionality
+--FILE--
+<?php
+/* Prototype : proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
+ * Description: Perform a Perl-style regular expression match
+ * Source code: ext/pcre/php_pcre.c
+ * Alias to functions:
+*/
+
+
+$string = 'Hello, world. [*], this is \ a string';
+
+var_dump(preg_match('/^[hH]ello,\s/', $string, $match1)); //finds "Hello, "
+var_dump($match1);
+
+var_dump(preg_match('/l^o,\s\w{5}/', $string, $match2, PREG_OFFSET_CAPTURE)); // tries to find "lo, world" at start of string
+var_dump($match2);
+
+var_dump(preg_match('/\[\*\],\s(.*)/', $string, $match3)); //finds "[*], this is \ a string";
+var_dump($match3);
+
+var_dump(preg_match('@\w{4}\s\w{2}\s\\\(?:\s.*)@', $string, $match4, PREG_OFFSET_CAPTURE, 14)); //finds "this is \ a string" (with non-capturing parentheses)
+var_dump($match4);
+
+var_dump(preg_match('/hello world/', $string, $match5)); //tries to find "hello world" (should be Hello, world)
+var_dump($match5);
+?>
+
+--EXPECTF--
+
+int(1)
+array(1) {
+ [0]=>
+ string(7) "Hello, "
+}
+int(0)
+array(0) {
+}
+int(1)
+array(2) {
+ [0]=>
+ string(23) "[*], this is \ a string"
+ [1]=>
+ string(18) "this is \ a string"
+}
+int(1)
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(18) "this is \ a string"
+ [1]=>
+ int(19)
+ }
+}
+int(0)
+array(0) {
+}
+
diff --git a/ext/pcre/tests/preg_match_error.phpt b/ext/pcre/tests/preg_match_error.phpt
new file mode 100644
index 0000000..ca1f128
--- /dev/null
+++ b/ext/pcre/tests/preg_match_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test preg_match() function : error conditions - wrong numbers of parameters
+--FILE--
+<?php
+/*
+ * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
+ * Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "*** Testing preg_match() : error conditions ***\n";
+// Zero arguments
+echo "\n-- Testing preg_match() function with Zero arguments --\n";
+var_dump(preg_match());
+//Test preg_match with one more than the expected number of arguments
+echo "\n-- Testing preg_match() function with more than expected no. of arguments --\n";
+$pattern = '/\w/';
+$subject = 'string_val';
+$flags = PREG_OFFSET_CAPTURE;
+$offset = 10;
+$extra_arg = 10;
+var_dump(preg_match($pattern, $subject, $matches, $flags, $offset, $extra_arg));
+// Testing preg_match withone less than the expected number of arguments
+echo "\n-- Testing preg_match() function with less than expected no. of arguments --\n";
+$pattern = '/\w/';
+var_dump(preg_match($pattern));
+echo "Done"
+?>
+--EXPECTF--
+*** Testing preg_match() : error conditions ***
+
+-- Testing preg_match() function with Zero arguments --
+
+Warning: preg_match() expects at least 2 parameters, 0 given in %spreg_match_error.php on line %d
+bool(false)
+
+-- Testing preg_match() function with more than expected no. of arguments --
+
+Warning: preg_match() expects at most 5 parameters, 6 given in %spreg_match_error.php on line %d
+bool(false)
+
+-- Testing preg_match() function with less than expected no. of arguments --
+
+Warning: preg_match() expects at least 2 parameters, 1 given in %spreg_match_error.php on line %d
+bool(false)
+Done
diff --git a/ext/pcre/tests/preg_match_error1.phpt b/ext/pcre/tests/preg_match_error1.phpt
new file mode 100644
index 0000000..7630481
--- /dev/null
+++ b/ext/pcre/tests/preg_match_error1.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Test preg_match() function : error conditions - bad regular expressions
+--FILE--
+<?php
+/*
+ * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
+ * Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_match reacts to being passed the wrong type of regex argument
+*/
+echo "*** Testing preg_match() : error conditions ***\n";
+$regex_array = array('abcdef', //Regex without delimeter
+'/[a-zA-Z]', //Regex without closing delimeter
+'[a-zA-Z]/', //Regex without opening delimeter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
+);
+$subject = 'this is a test';
+foreach($regex_array as $regex_value) {
+ print "\nArg value is $regex_value\n";
+ var_dump(preg_match($regex_value, $subject));
+}
+$regex_value = new stdclass(); //Object
+var_dump(preg_match($regex_value, $subject));
+?>
+--EXPECTF--
+
+*** Testing preg_match() : error conditions ***
+
+Arg value is abcdef
+
+Warning: preg_match(): Delimiter must not be alphanumeric or backslash in %spreg_match_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_match(): No ending delimiter '/' found in %spreg_match_error1.php on line %d
+bool(false)
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_match(): Unknown modifier '/' in %spreg_match_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_match(): Unknown modifier 'F' in %spreg_match_error1.php on line %d
+bool(false)
+
+Arg value is Array
+
+Warning: preg_match() expects parameter 1 to be string, array given in %spreg_match_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]/
+int(1)
+
+Warning: preg_match() expects parameter 1 to be string, object given in %spreg_match_error1.php on line %d
+bool(false)
diff --git a/ext/pcre/tests/preg_match_error2.phpt b/ext/pcre/tests/preg_match_error2.phpt
new file mode 100644
index 0000000..f30fb48
--- /dev/null
+++ b/ext/pcre/tests/preg_match_error2.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test preg_match() function : error conditions - wrong arg types
+--FILE--
+<?php
+/*
+ * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
+ * Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_match reacts to being passed the wrong type of subject argument
+*/
+echo "*** Testing preg_match() : error conditions ***\n";
+$regex = '/[a-zA-Z]/';
+$input = array('this is a string', array('this is', 'a subarray'),);
+foreach($input as $value) {
+ print "\nArg value is: $value\n";
+ var_dump(preg_match($regex, $value));
+}
+$value = new stdclass(); //Object
+var_dump(preg_match($regex, $value));
+echo "Done";
+?>
+--EXPECTF--
+
+*** Testing preg_match() : error conditions ***
+
+Arg value is: this is a string
+int(1)
+
+Arg value is: Array
+
+Warning: preg_match() expects parameter 2 to be string, array given in %spreg_match_error2.php on line %d
+bool(false)
+
+Warning: preg_match() expects parameter 2 to be string, object given in %spreg_match_error2.php on line %d
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/preg_match_variation1.phpt b/ext/pcre/tests/preg_match_variation1.phpt
new file mode 100644
index 0000000..a289ee4
--- /dev/null
+++ b/ext/pcre/tests/preg_match_variation1.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test preg_match() function : variation
+--FILE--
+<?php
+/*
+ * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]])
+ * Function is implemented in ext/pcre/php_pcre.c
+*/
+
+//test passing in the same variable where 1 is by value, the other is a different
+//type and by reference so should be updated to the new type.
+$string = "-1";
+preg_match('/[\-\+]?[0-9\.]*/', $string, $string);
+var_dump($string);
+?>
+===Done===
+--EXPECT--
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+===Done===
diff --git a/ext/pcre/tests/preg_quote_basic.phpt b/ext/pcre/tests/preg_quote_basic.phpt
new file mode 100644
index 0000000..c78f566
--- /dev/null
+++ b/ext/pcre/tests/preg_quote_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test preg_quote() function : basic functionality
+--FILE--
+<?php
+/*
+* proto string preg_quote(string str [, string delim_char])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+$string_before = '/this *-has \ metacharacters^ in $';
+print "\$string_before looks like: $string_before\n"; //$string_before is printed as is written
+$string_after = preg_quote($string_before, '/');
+print "\$string_after looks like: $string_after, with metacharacters and / (set as delimiter) escaped\n"; //$string_after is printed with metacharacters escaped.
+$string1 = 'testing - /this *-has \ metacharacters^ in $ should work';
+var_dump(preg_match('/^[tT]\w{6} - ' . preg_quote($string_before, '/') . ' [a-z]*\s*work$/', $string1, $matches1));
+var_dump($matches1);
+?>
+--EXPECT--
+
+$string_before looks like: /this *-has \ metacharacters^ in $
+$string_after looks like: \/this \*\-has \\ metacharacters\^ in \$, with metacharacters and / (set as delimiter) escaped
+int(1)
+array(1) {
+ [0]=>
+ string(58) "testing - /this *-has \ metacharacters^ in $ should work"
+} \ No newline at end of file
diff --git a/ext/pcre/tests/preg_quote_error.phpt b/ext/pcre/tests/preg_quote_error.phpt
new file mode 100644
index 0000000..30b832d
--- /dev/null
+++ b/ext/pcre/tests/preg_quote_error.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test preg_quote() function : error conditions - wrong numbers of parameters
+--FILE--
+<?php
+/*
+* proto string preg_quote(string str [, string delim_char])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "*** Testing preg_quote() : error conditions ***\n";
+// Zero arguments
+echo "\n-- Testing preg_quote() function with Zero arguments --\n";
+var_dump(preg_quote());
+//Test preg_quote with one more than the expected number of arguments
+echo "\n-- Testing preg_quote() function with more than expected no. of arguments --\n";
+$str = 'string_val';
+$delim_char = '/';
+$extra_arg = 10;
+var_dump(preg_quote($str, $delim_char, $extra_arg));
+echo "Done"
+?>
+--EXPECTF--
+*** Testing preg_quote() : error conditions ***
+
+-- Testing preg_quote() function with Zero arguments --
+
+Warning: preg_quote() expects at least 1 parameter, 0 given in %spreg_quote_error.php on line %d
+NULL
+
+-- Testing preg_quote() function with more than expected no. of arguments --
+
+Warning: preg_quote() expects at most 2 parameters, 3 given in %spreg_quote_error.php on line %d
+NULL
+Done
diff --git a/ext/pcre/tests/preg_quote_error1.phpt b/ext/pcre/tests/preg_quote_error1.phpt
new file mode 100644
index 0000000..a02c836
--- /dev/null
+++ b/ext/pcre/tests/preg_quote_error1.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test preg_quote() function : error conditions - wrong arg types
+--FILE--
+<?php
+/*
+* proto string preg_quote(string str [, string delim_char])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_quote reacts to being passed the wrong type of input argument
+*/
+echo "*** Testing preg_quote() : error conditions ***\n";
+$input = array('this is a string', array('this is', 'a subarray'),);
+foreach($input as $value) {
+ print "\nArg value is: $value\n";
+ var_dump(preg_quote($value));
+}
+$value = new stdclass(); //Object
+var_dump(preg_quote($value));
+echo "Done";
+?>
+--EXPECTF--
+*** Testing preg_quote() : error conditions ***
+
+Arg value is: this is a string
+string(16) "this is a string"
+
+Arg value is: Array
+
+Warning: preg_quote() expects parameter 1 to be string, array given in %spreg_quote_error1.php on line %d
+NULL
+
+Warning: preg_quote() expects parameter 1 to be string, object given in %spreg_quote_error1.php on line %d
+NULL
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/preg_replace.phpt b/ext/pcre/tests/preg_replace.phpt
new file mode 100644
index 0000000..f7b5f74
--- /dev/null
+++ b/ext/pcre/tests/preg_replace.phpt
@@ -0,0 +1,25 @@
+--TEST--
+preg_replace()
+--FILE--
+<?php
+
+var_dump(preg_replace('{{\D+}}', 'x', '{abcd}'));
+var_dump(preg_replace('{{\D+}}', 'ddd', 'abcd'));
+
+var_dump(preg_replace('/(ab)(c)(d)(e)(f)(g)(h)(i)(j)(k)/', 'a${1}2$103', 'zabcdefghijkl'));
+
+var_dump(preg_replace_callback('//e', '', ''));
+
+var_dump(preg_replace_callback('//e', 'strtolower', ''));
+
+?>
+--EXPECTF--
+string(1) "x"
+string(4) "abcd"
+string(8) "zaab2k3l"
+
+Warning: preg_replace_callback(): Requires argument 2, '', to be a valid callback in %spreg_replace.php on line 8
+string(0) ""
+
+Warning: preg_replace_callback(): Modifier /e cannot be used with replacement callback in %spreg_replace.php on line 10
+NULL
diff --git a/ext/pcre/tests/preg_replace2.phpt b/ext/pcre/tests/preg_replace2.phpt
new file mode 100644
index 0000000..4a191f3
--- /dev/null
+++ b/ext/pcre/tests/preg_replace2.phpt
@@ -0,0 +1,48 @@
+--TEST--
+preg_replace()
+--SKIPIF--
+<?php
+if (@preg_match('/./u', '') === false) {
+ die('skip no utf8 support in PCRE library');
+}
+?>
+--FILE--
+<?php
+
+var_dump(preg_replace('', array(), ''));
+
+var_dump(preg_replace(array('/\da(.)/ui', '@..@'), '$1', '12Abc'));
+var_dump(preg_replace(array('/\da(.)/ui', '@(.)@'), '$1', array('x','a2aA', '1av2Ab')));
+
+
+var_dump(preg_replace(array('/[\w]+/'), array('$'), array('xyz', 'bdbd')));
+var_dump(preg_replace(array('/\s+/', '~[b-d]~'), array('$'), array('x y', 'bd bc')));
+
+echo "==done==\n";
+
+?>
+--EXPECTF--
+Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace2.php on line 3
+bool(false)
+string(1) "c"
+array(3) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ string(2) "aA"
+ [2]=>
+ string(2) "vb"
+}
+array(2) {
+ [0]=>
+ string(1) "$"
+ [1]=>
+ string(1) "$"
+}
+array(2) {
+ [0]=>
+ string(3) "x$y"
+ [1]=>
+ string(1) "$"
+}
+==done==
diff --git a/ext/pcre/tests/preg_replace_basic.phpt b/ext/pcre/tests/preg_replace_basic.phpt
new file mode 100644
index 0000000..33fb2d4
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test preg_replace() function : basic functionality
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+$string = '123456789 - Hello, world - This is a string.';
+var_dump($string);
+var_dump(preg_replace('<- This is a string$>', 'This shouldn\'t work', $string)); //tries to find '- This is a string' at the end of a string but can't so replaces nothing and prints the unchanged $string.
+var_dump(preg_replace('<[0-35-9]>', '4', $string)); //finds any number that's not 4 and replaces it with a 4 ('444444444')
+var_dump(preg_replace('<\b[hH]\w{2,4}>', 'Bonjour', $string)); //finds h or H at the beginning of a word followed by 2-4 characters and replaces it with Bonjour (i.e. Hello -> Bonjour) (was finding the 'his' in This and replacing it)
+var_dump(preg_replace('<(\w)\s*-\s*(\w)>', '\\1. \\2', $string)); //finds dashes with an indefinate amount of whitespace around them and replaces them with a full stop precedeby no spaces and followed by one space
+var_dump(preg_replace('<(^[a-z]\w+)@(\w+)\.(\w+)\.([a-z]{2,}$)>', '\\1 at \\2 dot \\3 dot \\4', 'josmessa@uk.ibm.com')); //finds the e-mail address and replaces the @ and . with "at" and "dot" (uses backreferences) ('josmessa at uk dot ibm dot com')
+
+?>
+--EXPECT--
+
+string(54) "123456789 - Hello, world - This is a string."
+string(54) "123456789 - Hello, world - This is a string."
+string(54) "444444444 - Hello, world - This is a string."
+string(56) "123456789 - Bonjour, world - This is a string."
+string(42) "123456789. Hello, world. This is a string."
+string(30) "josmessa at uk dot ibm dot com"
diff --git a/ext/pcre/tests/preg_replace_callback.phpt b/ext/pcre/tests/preg_replace_callback.phpt
new file mode 100644
index 0000000..0b0bc27
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback.phpt
@@ -0,0 +1,25 @@
+--TEST--
+preg_replace_callback()
+--FILE--
+<?php
+$input = "plain [indent] deep [indent] [abcd]deeper[/abcd] [/indent] deep [/indent] plain";
+
+function parseTagsRecursive($input)
+{
+
+ $regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#';
+
+ if (is_array($input)) {
+ $input = '<div style="margin-left: 10px">'.$input[1].'</div>';
+ }
+
+ return preg_replace_callback($regex, 'parseTagsRecursive', $input);
+}
+
+$output = parseTagsRecursive($input);
+
+echo $output, "\n";
+
+?>
+--EXPECT--
+plain <div style="margin-left: 10px"> deep <div style="margin-left: 10px"> [abcd]deeper[/abcd] </div> deep </div> plain
diff --git a/ext/pcre/tests/preg_replace_callback2.phpt b/ext/pcre/tests/preg_replace_callback2.phpt
new file mode 100644
index 0000000..7989509
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback2.phpt
@@ -0,0 +1,39 @@
+--TEST--
+preg_replace_callback() 2
+--FILE--
+<?php
+
+function f() {
+ throw new Exception();
+}
+
+try {
+var_dump(preg_replace_callback('/\w/', 'f', 'z'));
+} catch(Exception $e) {}
+
+function g($x) {
+ return "'$x[0]'";
+}
+
+var_dump(preg_replace_callback('@\b\w{1,2}\b@', 'g', array('a b3 bcd', 'v' => 'aksfjk', 12 => 'aa bb')));
+
+var_dump(preg_replace_callback('~\A.~', 'g', array(array('xyz'))));
+
+var_dump(preg_replace_callback('~\A.~', create_function('$m', 'return strtolower($m[0]);'), 'ABC'));
+?>
+--EXPECTF--
+array(3) {
+ [0]=>
+ string(12) "'a' 'b3' bcd"
+ ["v"]=>
+ string(6) "aksfjk"
+ [12]=>
+ string(9) "'aa' 'bb'"
+}
+
+Notice: Array to string conversion in %spreg_replace_callback2.php on line 17
+array(1) {
+ [0]=>
+ string(7) "'A'rray"
+}
+string(3) "aBC"
diff --git a/ext/pcre/tests/preg_replace_callback3.phpt b/ext/pcre/tests/preg_replace_callback3.phpt
new file mode 100644
index 0000000..30799e2
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback3.phpt
@@ -0,0 +1,44 @@
+--TEST--
+preg_replace_callback() 3
+--FILE--
+<?php
+
+var_dump(preg_replace_callback());
+var_dump(preg_replace_callback(1));
+var_dump(preg_replace_callback(1,2));
+var_dump(preg_replace_callback(1,2,3));
+var_dump(preg_replace_callback(1,2,3,4));
+$a = 5;
+var_dump(preg_replace_callback(1,2,3,4,$a));
+$a = "";
+var_dump(preg_replace_callback("","","","",$a));
+$a = array();
+var_dump(preg_replace_callback($a,$a,$a,$a,$a));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
+NULL
+
+Warning: preg_replace_callback() expects at least 3 parameters, 1 given in %s on line %d
+NULL
+
+Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+
+Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
+int(3)
+
+Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
+int(3)
+
+Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
+int(3)
+
+Warning: preg_replace_callback() expects parameter 4 to be long, string given in %s on line %d
+NULL
+
+Warning: preg_replace_callback() expects parameter 4 to be long, array given in %s on line %d
+NULL
+Done
diff --git a/ext/pcre/tests/preg_replace_callback_basic.phpt b/ext/pcre/tests/preg_replace_callback_basic.phpt
new file mode 100644
index 0000000..01d290a
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test preg_replace_callback() function : basic functionality
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+/*
+* Basic test for preg_replace_callback
+*/
+$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'); //array will have the default key values (0-9) and each value is the corresponding key written in words.
+function integer_word($matches) {
+ global $replacement;
+ return $replacement[$matches[0]]; //all examples will be looking for an integer value, if one is found it will be stored in $matches[0] which corresponds to a key in the $replacements array
+
+}
+$subject1 = 'there are 7 words in this sentence.';
+$new_subject1 = preg_replace_callback('/\d/', "integer_word", $subject1);
+print "$new_subject1 \n";
+$subject2 = '1 2 3 4 is now written in words';
+$new_subject2 = preg_replace_callback('/\d/', "integer_word", $subject2, 3); //limits to three replacements
+print "$new_subject2 \n";
+$subject3 = 'there are no numbers in this string';
+$new_subject3 = preg_replace_callback('/\d/', "integer_word", $subject3, 5, $count); //limites to five replacements and counts the number of replacements made ands stores in $count variable
+print "$new_subject3 \n";
+print $count;
+?>
+--EXPECTF--
+there are seven words in this sentence.
+one two three 4 is now written in words
+there are no numbers in this string
+0
diff --git a/ext/pcre/tests/preg_replace_callback_error.phpt b/ext/pcre/tests/preg_replace_callback_error.phpt
new file mode 100644
index 0000000..9371fcf
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback_error.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test preg_replace_callback() function : error
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "***Testing preg_replace_callback() : error conditions***\n";
+//Zero arguments
+echo "\n-- Testing preg_replace_callback() function with Zero arguments --\n";
+var_dump(preg_replace_callback());
+//Test preg_replace_callback() with one more than the expected number of arguments
+echo "\n-- Testing preg_replace_callback() function with more than expected no. of arguments --\n";
+$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
+function integer_word($matches) {
+ global $replacement;
+ return $replacement[$matches[0]];
+}
+$regex = '/\d/';
+$subject = 'there are 7 words in this sentence.';
+$limit = 10;
+$extra_arg = 10;
+var_dump(preg_replace_callback($regex, 'integer_word', $subject, $limit, $count, $extra_arg));
+//Testing preg_replace_callback() with one less than the expected number of arguments
+echo "\n-- Testing preg_replace_callback() function with less than expected no. of arguments --\n";
+$regex = '/\d/';
+var_dump(preg_replace_callback($regex, 'integer word'));
+echo "Done";
+?>
+--EXPECTF--
+***Testing preg_replace_callback() : error conditions***
+
+-- Testing preg_replace_callback() function with Zero arguments --
+
+Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
+NULL
+
+-- Testing preg_replace_callback() function with more than expected no. of arguments --
+
+Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %s on line %d
+NULL
+
+-- Testing preg_replace_callback() function with less than expected no. of arguments --
+
+Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+Done
diff --git a/ext/pcre/tests/preg_replace_callback_error1.phpt b/ext/pcre/tests/preg_replace_callback_error1.phpt
new file mode 100644
index 0000000..a00b97c
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_callback_error1.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test preg_replace_callback() function : error
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_replace_callback reacts to being passed the wrong type of regex argument
+*/
+echo "*** Testing preg_replace_callback() : error conditions ***\n";
+$regex_array = array('abcdef', //Regex without delimiters
+'/[a-zA-Z]', //Regex without closing delimiter
+'[a-zA-Z]/', //Regex without opening delimiter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/'); //Regex string
+$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
+function integer_word($matches) {
+ global $replacement;
+ return $replacement[$matches[0]];
+}
+$subject = 'number 1.';
+foreach($regex_array as $regex_value) {
+ print "\nArg value is $regex_value\n";
+ var_dump(preg_replace_callback($regex_value, 'integer_word', $subject));
+}
+?>
+===Done===
+--EXPECTF--
+*** Testing preg_replace_callback() : error conditions ***
+
+Arg value is abcdef
+
+Warning: preg_replace_callback(): Delimiter must not be alphanumeric or backslash in %s on line %d
+NULL
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_replace_callback(): No ending delimiter '/' found in %s on line %d
+NULL
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_replace_callback(): Unknown modifier '/' in %s on line %d
+NULL
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_replace_callback(): Unknown modifier 'F' in %s on line %d
+NULL
+
+Arg value is Array
+string(9) "number 1."
+
+Arg value is /[a-zA-Z]/
+string(3) " 1."
+===Done=== \ No newline at end of file
diff --git a/ext/pcre/tests/preg_replace_edit_basic.phpt b/ext/pcre/tests/preg_replace_edit_basic.phpt
new file mode 100644
index 0000000..97350e7
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_edit_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Test preg_replace() function : basic
+--FILE--
+<?php
+/* Prototype : proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+ * Description: Perform Perl-style regular expression replacement.
+ * Source code: ext/pcre/php_pcre.c
+ * Alias to functions:
+*/
+
+$string = '123456789 - Hello, world - This is a string.';
+var_dump($string);
+
+var_dump(preg_replace('<- This is a string$>',
+ 'This shouldn\'t work', $string)); //tries to find '- This is a string' at the end of a string but can't so replaces nothing and prints the unchanged $string.
+
+var_dump(preg_replace('<[0-35-9]>',
+ '4', $string, //finds any number that's not 4 and replaces it with a 4
+ '5', $count)); //limits to 5 replacements returns 444444789
+var_dump($count); //counts the number of replacements made (5)
+
+
+var_dump(preg_replace('<\b[hH]\w{2,4}>',
+ 'Bonjour', $string)); //finds h or H at the beginning of a word followed by 2-4 characters and replaces it with Bonjour (i.e. Hello -> Bonjour) (was finding the 'his' in This and replacing it)
+
+var_dump(preg_replace('<(\w)\s*-\s*(\w)>',
+ '\\1. \\2', $string)); //finds dashes with an indefinate amount of whitespace around them and replaces them with a full stop precedeby no spaces and followed by one space
+
+var_dump(preg_replace('<(^[a-z]\w+)@(\w+)\.(\w+)\.([a-z]{2,}$)>',
+ '\\1 at \\2 dot \\3 dot \\4', 'josmessa@uk.ibm.com')); //finds the e-mail address and replaces the @ and . with "at" and "dot" (uses backreferences) ('josmessa at uk dot ibm dot com')
+?>
+--EXPECTF--
+string(54) "123456789 - Hello, world - This is a string."
+string(54) "123456789 - Hello, world - This is a string."
+string(54) "444444789 - Hello, world - This is a string."
+int(5)
+string(56) "123456789 - Bonjour, world - This is a string."
+string(42) "123456789. Hello, world. This is a string."
+string(30) "josmessa at uk dot ibm dot com"
diff --git a/ext/pcre/tests/preg_replace_error.phpt b/ext/pcre/tests/preg_replace_error.phpt
new file mode 100644
index 0000000..fc3427d
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_error.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test preg_replace() function : error - incorrect number of parameters
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "*** Testing preg_replace() : error conditions ***\n";
+//Zero arguments
+echo "\n-- Testing preg_replace() function with zero arguments --\n";
+var_dump(preg_replace());
+//Test preg_replace() with one more than the expected number of arguments
+echo "\n-- Testing preg_replace() function with more than expected no. of arguments --\n";
+$regex = '/\w/';
+$replace = '1';
+$subject = 'string_val';
+$limit = 10;
+$extra_arg = 10;
+var_dump(preg_replace($regex, $replace, $subject, $limit, $count, $extra_arg));
+//Testing preg_replace() with one less than the expected number of arguments
+echo "\n-- Testing preg_replace() function with less than expected no. of arguments --\n";
+$regex = '/\w/';
+$replace = '1';
+var_dump(preg_replace($regex, $replace));
+echo "Done"
+?>
+--EXPECTF--
+*** Testing preg_replace() : error conditions ***
+
+-- Testing preg_replace() function with zero arguments --
+
+Warning: preg_replace() expects at least 3 parameters, 0 given in %s on line %d
+NULL
+
+-- Testing preg_replace() function with more than expected no. of arguments --
+
+Warning: preg_replace() expects at most 5 parameters, 6 given in %s on line %d
+NULL
+
+-- Testing preg_replace() function with less than expected no. of arguments --
+
+Warning: preg_replace() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+Done
diff --git a/ext/pcre/tests/preg_replace_error1.phpt b/ext/pcre/tests/preg_replace_error1.phpt
new file mode 100644
index 0000000..7ddfcfd
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_error1.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test preg_replace() function : error - bad regular expressions
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_replace reacts to being passed the wrong type of regex argument
+*/
+echo "*** Testing preg_replace() : error conditions***\n";
+$regex_array = array('abcdef', //Regex without delimeter
+'/[a-zA-Z]', //Regex without closing delimeter
+'[a-zA-Z]/', //Regex without opening delimeter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
+);
+$replace = 1;
+$subject = 'a';
+foreach($regex_array as $regex_value) {
+ print "\nArg value is $regex_value\n";
+ var_dump(preg_replace($regex_value, $replace, $subject));
+}
+$regex_value = new stdclass(); //Object
+var_dump(preg_replace($regex_value, $replace, $subject));
+?>
+--EXPECTF--
+*** Testing preg_replace() : error conditions***
+
+Arg value is abcdef
+
+Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in %spreg_replace_error1.php on line %d
+NULL
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_replace(): No ending delimiter '/' found in %spreg_replace_error1.php on line %d
+NULL
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_replace(): Unknown modifier '/' in %spreg_replace_error1.php on line %d
+NULL
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_replace(): Unknown modifier 'F' in %spreg_replace_error1.php on line %d
+NULL
+
+Arg value is Array
+string(1) "a"
+
+Arg value is /[a-zA-Z]/
+string(1) "1"
+
+Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error1.php on line %d
+
diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt
new file mode 100644
index 0000000..bf5d3e0
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_error2.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test preg_replace() function : error conditions - wrong arg types
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_replace reacts to being passed the wrong type of replacement argument
+*/
+echo "*** Testing preg_replace() : error conditions ***\n";
+$regex = '/[a-zA-Z]/';
+$replace = array('this is a string', array('this is', 'a subarray'),);
+$subject = 'test';
+foreach($replace as $value) {
+ print "\nArg value is: $value\n";
+ var_dump(preg_replace($regex, $value, $subject));
+}
+$value = new stdclass(); //Object
+var_dump(preg_replace($regex, $value, $subject));
+echo "Done";
+?>
+--EXPECTF--
+*** Testing preg_replace() : error conditions ***
+
+Arg value is: this is a string
+string(64) "this is a stringthis is a stringthis is a stringthis is a string"
+
+Arg value is: Array
+
+Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d
+bool(false)
+
+Catchable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error2.php on line %d
+
diff --git a/ext/pcre/tests/preg_replace_variation1.phpt b/ext/pcre/tests/preg_replace_variation1.phpt
new file mode 100644
index 0000000..ac79e0b
--- /dev/null
+++ b/ext/pcre/tests/preg_replace_variation1.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test preg_replace() function : variation both arguments are arrays
+--FILE--
+<?php
+/*
+* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+/*
+* Testing preg_replace when the regex and the replacement are both arrays.
+*/
+$string = 'This is a string. It contains numbers (0-9) as well as parentheses and some other things!';
+$new_string = preg_replace(array('/\b\w{1}s/', '/(\d{1})-(\d{1})/', '/[\(!\)]/'), array('test', '$1 to $2', '*'), $string);
+print $new_string;
+?>
+--EXPECTF--
+This test a string. It contains numbers *0 to 9* test well test parentheses and some other things*
diff --git a/ext/pcre/tests/preg_split_basic.phpt b/ext/pcre/tests/preg_split_basic.phpt
new file mode 100644
index 0000000..e94a94f
--- /dev/null
+++ b/ext/pcre/tests/preg_split_basic.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test preg_split() function : basic functionality
+--FILE--
+<?php
+/*
+* proto array preg_split(string pattern, string subject [, int limit [, int flags]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+$string = 'this is a_list: value1, Test__, string; Hello, world!_(parentheses)';
+var_dump(preg_split('/[:,;\(\)]/', $string, -1, PREG_SPLIT_NO_EMPTY)); //parts of $string seperated by : , ; ( or ) are put into an array.
+var_dump(preg_split('/:\s*(\w*,*\s*)+;/', $string)); //all text between : and ; is removed
+var_dump(preg_split('/(\(|\))/', $string, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY)); //all text before (parentheses) is put into first element, ( into second, "parentheses" into third and ) into fourth.
+var_dump(preg_split('/NAME/i', $string)); //tries to find NAME regardless of case in $string (can't split it so just returns how string as first element)
+var_dump(preg_split('/\w/', $string, -1, PREG_SPLIT_NO_EMPTY)); //every character (including whitespace) is put into an array element
+
+?>
+--EXPECT--
+array(7) {
+ [0]=>
+ string(14) "this is a_list"
+ [1]=>
+ string(7) " value1"
+ [2]=>
+ string(7) " Test__"
+ [3]=>
+ string(7) " string"
+ [4]=>
+ string(6) " Hello"
+ [5]=>
+ string(8) " world!_"
+ [6]=>
+ string(11) "parentheses"
+}
+array(2) {
+ [0]=>
+ string(14) "this is a_list"
+ [1]=>
+ string(28) " Hello, world!_(parentheses)"
+}
+array(4) {
+ [0]=>
+ string(54) "this is a_list: value1, Test__, string; Hello, world!_"
+ [1]=>
+ string(1) "("
+ [2]=>
+ string(11) "parentheses"
+ [3]=>
+ string(1) ")"
+}
+array(1) {
+ [0]=>
+ string(67) "this is a_list: value1, Test__, string; Hello, world!_(parentheses)"
+}
+array(10) {
+ [0]=>
+ string(1) " "
+ [1]=>
+ string(1) " "
+ [2]=>
+ string(2) ": "
+ [3]=>
+ string(2) ", "
+ [4]=>
+ string(2) ", "
+ [5]=>
+ string(2) "; "
+ [6]=>
+ string(2) ", "
+ [7]=>
+ string(1) "!"
+ [8]=>
+ string(1) "("
+ [9]=>
+ string(1) ")"
+}
diff --git a/ext/pcre/tests/preg_split_error.phpt b/ext/pcre/tests/preg_split_error.phpt
new file mode 100644
index 0000000..960b286
--- /dev/null
+++ b/ext/pcre/tests/preg_split_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test preg_split() function : error conditions - incorrect number of parameters
+--FILE--
+<?php
+/*
+* proto array preg_split(string pattern, string subject [, int limit [, int flags]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+echo "*** Testing preg_split() : error conditions ***\n";
+// Zero arguments
+echo "\n-- Testing preg_split() function with Zero arguments --\n";
+var_dump(preg_split());
+//Test preg_split with one more than the expected number of arguments
+echo "\n-- Testing preg_split() function with more than expected no. of arguments --\n";
+$pattern = '/_/';
+$subject = 'string_val';
+$limit = 10;
+$flags = PREG_SPLIT_NO_EMPTY;
+$extra_arg = 10;
+var_dump(preg_split($pattern, $subject, $limit, $flags, $extra_arg));
+// Testing preg_split withone less than the expected number of arguments
+echo "\n-- Testing preg_split() function with less than expected no. of arguments --\n";
+$pattern = '/\./';
+var_dump(preg_split($pattern));
+echo "Done"
+?>
+--EXPECTF--
+*** Testing preg_split() : error conditions ***
+
+-- Testing preg_split() function with Zero arguments --
+
+Warning: preg_split() expects at least 2 parameters, 0 given in %spreg_split_error.php on line %d
+bool(false)
+
+-- Testing preg_split() function with more than expected no. of arguments --
+
+Warning: preg_split() expects at most 4 parameters, 5 given in %spreg_split_error.php on line %d
+bool(false)
+
+-- Testing preg_split() function with less than expected no. of arguments --
+
+Warning: preg_split() expects at least 2 parameters, 1 given in %spreg_split_error.php on line %d
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/preg_split_error1.phpt b/ext/pcre/tests/preg_split_error1.phpt
new file mode 100644
index 0000000..79942a9
--- /dev/null
+++ b/ext/pcre/tests/preg_split_error1.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Test preg_split() function : error conditions - bad regular expressions
+--FILE--
+<?php
+/*
+* proto array preg_split(string pattern, string subject [, int limit [, int flags]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_split reacts to being passed the wrong type of regex argument
+*/
+echo "*** Testing preg_split() : error conditions ***\n";
+$regex_array = array('abcdef', //Regex without delimiter
+'/[a-zA-Z]', //Regex without closing delimiter
+'[a-zA-Z]/', //Regex without opening delimiter
+'/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
+'[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
+);
+$subject = '1 2 a 3 4 b 5 6';
+foreach($regex_array as $regex_value) {
+ print "\nArg value is $regex_value\n";
+ var_dump(preg_split($regex_value, $subject));
+}
+$regex_value = new stdclass(); //Object
+var_dump(preg_split($regex_value, $subject));
+?>
+--EXPECTF--
+*** Testing preg_split() : error conditions ***
+
+Arg value is abcdef
+
+Warning: preg_split(): Delimiter must not be alphanumeric or backslash in %spreg_split_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]
+
+Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d
+bool(false)
+
+Arg value is [a-zA-Z]/
+
+Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]/F
+
+Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d
+bool(false)
+
+Arg value is Array
+
+Warning: preg_split() expects parameter 1 to be string, array given in %spreg_split_error1.php on line %d
+bool(false)
+
+Arg value is /[a-zA-Z]/
+array(3) {
+ [0]=>
+ string(4) "1 2 "
+ [1]=>
+ string(5) " 3 4 "
+ [2]=>
+ string(4) " 5 6"
+}
+
+Warning: preg_split() expects parameter 1 to be string, object given in %spreg_split_error1.php on line %d
+bool(false)
diff --git a/ext/pcre/tests/preg_split_error2.phpt b/ext/pcre/tests/preg_split_error2.phpt
new file mode 100644
index 0000000..e081821
--- /dev/null
+++ b/ext/pcre/tests/preg_split_error2.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Test preg_split() function : error conditions - wrong arg types
+--FILE--
+<?php
+/*
+* proto array preg_split(string pattern, string subject [, int limit [, int flags]])
+* Function is implemented in ext/pcre/php_pcre.c
+*/
+error_reporting(E_ALL&~E_NOTICE);
+/*
+* Testing how preg_split reacts to being passed the wrong type of input argument
+*/
+echo "*** Testing preg_split() : error conditions ***\n";
+$regex = '/[a-zA-Z]/';
+$input = array(array('this is', 'a subarray'),);
+foreach($input as $value) {
+ print "\nArg value is: $value\n";
+ var_dump(preg_split($regex, $value));
+}
+$value = new stdclass(); //Object
+var_dump(preg_split($regex, $value));
+echo "Done";
+?>
+--EXPECTF--
+*** Testing preg_split() : error conditions ***
+
+Arg value is: Array
+
+Warning: preg_split() expects parameter 2 to be string, array given in %spreg_split_error2.php on line %d
+bool(false)
+
+Warning: preg_split() expects parameter 2 to be string, object given in %spreg_split_error2.php on line %d
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/pcre/tests/recursion_limit.phpt b/ext/pcre/tests/recursion_limit.phpt
new file mode 100644
index 0000000..7dee7ba
--- /dev/null
+++ b/ext/pcre/tests/recursion_limit.phpt
@@ -0,0 +1,25 @@
+--TEST--
+PCRE Recursion limit
+--SKIPIF--
+<?php
+if (@preg_match_all('/\p{N}/', '0123456789', $dummy) === false) {
+ die("skip no support for \p support PCRE library");
+}
+?>
+--INI--
+pcre.recursion_limit=2
+--FILE--
+<?php
+
+var_dump(preg_match_all('/\p{Ll}(\p{L}((\p{Ll}\p{Ll})))/', 'aeiou', $dummy));
+var_dump(preg_last_error() === PREG_RECURSION_LIMIT_ERROR);
+
+var_dump(preg_match_all('/\p{Ll}\p{L}\p{Ll}\p{Ll}/', 'aeiou', $dummy));
+var_dump(preg_last_error() === PREG_NO_ERROR);
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
+int(1)
+bool(true)
diff --git a/ext/pcre/tests/skip.ini b/ext/pcre/tests/skip.ini
new file mode 100644
index 0000000..1388e92
--- /dev/null
+++ b/ext/pcre/tests/skip.ini
@@ -0,0 +1,17 @@
+[Locale checks]
+skip[]=skip_001.inc
+test[]=locales.phpt
+
+[No utf8 support in PCRE library]
+skip[]=skip_002.inc
+test[]=007.phpt
+test[]=bug27103.phpt
+test[]=invalid_utf8_offset.phpt
+test[]=invalid_utf8.phpt
+test[]=preg_replace2.phpt
+
+[No support for \p support PCRE library]
+skip[]=skip_003.inc
+test[]=backtrack_limit.phpt
+test[]=pcre_anchored.phpt
+test[]=recursion_limit.phpt
diff --git a/ext/pcre/tests/skip_001.inc b/ext/pcre/tests/skip_001.inc
new file mode 100644
index 0000000..410512d
--- /dev/null
+++ b/ext/pcre/tests/skip_001.inc
@@ -0,0 +1,9 @@
+<?php
+
+if (!function_exists('setlocale')) {
+ die('skip: setlocale() not available');
+}
+
+if (!@setlocale(LC_ALL, 'pt_PT', 'pt', 'pt_PT.ISO8859-1', 'portuguese')) {
+ die('skip pt locale not available');
+}
diff --git a/ext/pcre/tests/skip_002.inc b/ext/pcre/tests/skip_002.inc
new file mode 100644
index 0000000..7f3a253
--- /dev/null
+++ b/ext/pcre/tests/skip_002.inc
@@ -0,0 +1,5 @@
+<?php
+
+if (@preg_match('/./u', '') === false) {
+ die('skip');
+}
diff --git a/ext/pcre/tests/skip_003.inc b/ext/pcre/tests/skip_003.inc
new file mode 100644
index 0000000..af2f548
--- /dev/null
+++ b/ext/pcre/tests/skip_003.inc
@@ -0,0 +1,5 @@
+<?php
+
+if (@preg_match_all('/\p{N}/', '0123456789', $dummy) === false) {
+ die('skip');
+}
diff --git a/ext/pcre/tests/split.phpt b/ext/pcre/tests/split.phpt
new file mode 100644
index 0000000..8ec8e65
--- /dev/null
+++ b/ext/pcre/tests/split.phpt
@@ -0,0 +1,86 @@
+--TEST--
+preg_split()
+--FILE--
+<?php
+
+var_dump(preg_split());
+var_dump(preg_split('/*/', 'x'));
+
+var_dump(preg_split('/[\s, ]+/', 'x yy,zzz'));
+var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', -1));
+var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 0));
+var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 1));
+var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 2));
+
+var_dump(preg_split('/\d*/', 'ab2c3u'));
+var_dump(preg_split('/\d*/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY));
+
+?>
+--EXPECTF--
+Warning: preg_split() expects at least 2 parameters, 0 given in %ssplit.php on line 3
+bool(false)
+
+Warning: preg_split(): Compilation failed: nothing to repeat at offset 0 in %ssplit.php on line 4
+bool(false)
+array(3) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ string(2) "yy"
+ [2]=>
+ string(3) "zzz"
+}
+array(3) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ string(2) "yy"
+ [2]=>
+ string(3) "zzz"
+}
+array(3) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ string(2) "yy"
+ [2]=>
+ string(3) "zzz"
+}
+array(1) {
+ [0]=>
+ string(8) "x yy,zzz"
+}
+array(2) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ string(6) "yy,zzz"
+}
+array(8) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(1) "a"
+ [2]=>
+ string(1) "b"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(1) "c"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(1) "u"
+ [7]=>
+ string(0) ""
+}
+array(4) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+ [3]=>
+ string(1) "u"
+}
diff --git a/ext/pcre/tests/split2.phpt b/ext/pcre/tests/split2.phpt
new file mode 100644
index 0000000..391acb9
--- /dev/null
+++ b/ext/pcre/tests/split2.phpt
@@ -0,0 +1,315 @@
+--TEST--
+preg_split() 2nd test
+--FILE--
+<?php
+
+var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE));
+var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_OFFSET_CAPTURE));
+var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
+var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE));;
+var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
+var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
+
+
+var_dump(preg_last_error(1));
+ini_set('pcre.recursion_limit', 1);
+var_dump(preg_last_error() == PREG_NO_ERROR);
+var_dump(preg_split('/(\d*)/', 'ab2c3u'));
+var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
+
+?>
+--EXPECTF--
+array(15) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(1) "a"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(1) "b"
+ [5]=>
+ string(1) "2"
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(0) ""
+ [8]=>
+ string(1) "c"
+ [9]=>
+ string(1) "3"
+ [10]=>
+ string(0) ""
+ [11]=>
+ string(0) ""
+ [12]=>
+ string(1) "u"
+ [13]=>
+ string(0) ""
+ [14]=>
+ string(0) ""
+}
+array(8) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(0)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(1) "b"
+ [1]=>
+ int(1)
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(3)
+ }
+ [4]=>
+ array(2) {
+ [0]=>
+ string(1) "c"
+ [1]=>
+ int(3)
+ }
+ [5]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(5)
+ }
+ [6]=>
+ array(2) {
+ [0]=>
+ string(1) "u"
+ [1]=>
+ int(5)
+ }
+ [7]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(6)
+ }
+}
+array(6) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "2"
+ [3]=>
+ string(1) "c"
+ [4]=>
+ string(1) "3"
+ [5]=>
+ string(1) "u"
+}
+array(4) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "b"
+ [1]=>
+ int(1)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(1) "c"
+ [1]=>
+ int(3)
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ string(1) "u"
+ [1]=>
+ int(5)
+ }
+}
+array(15) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(0)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(0)
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(1)
+ }
+ [4]=>
+ array(2) {
+ [0]=>
+ string(1) "b"
+ [1]=>
+ int(1)
+ }
+ [5]=>
+ array(2) {
+ [0]=>
+ string(1) "2"
+ [1]=>
+ int(2)
+ }
+ [6]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(3)
+ }
+ [7]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(3)
+ }
+ [8]=>
+ array(2) {
+ [0]=>
+ string(1) "c"
+ [1]=>
+ int(3)
+ }
+ [9]=>
+ array(2) {
+ [0]=>
+ string(1) "3"
+ [1]=>
+ int(4)
+ }
+ [10]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(5)
+ }
+ [11]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(5)
+ }
+ [12]=>
+ array(2) {
+ [0]=>
+ string(1) "u"
+ [1]=>
+ int(5)
+ }
+ [13]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(6)
+ }
+ [14]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ int(6)
+ }
+}
+array(6) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "b"
+ [1]=>
+ int(1)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ string(1) "2"
+ [1]=>
+ int(2)
+ }
+ [3]=>
+ array(2) {
+ [0]=>
+ string(1) "c"
+ [1]=>
+ int(3)
+ }
+ [4]=>
+ array(2) {
+ [0]=>
+ string(1) "3"
+ [1]=>
+ int(4)
+ }
+ [5]=>
+ array(2) {
+ [0]=>
+ string(1) "u"
+ [1]=>
+ int(5)
+ }
+}
+
+Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+bool(true)
+array(1) {
+ [0]=>
+ string(6) "ab2c3u"
+}
+bool(true)
diff --git a/ext/pcre/tests/study.phpt b/ext/pcre/tests/study.phpt
new file mode 100644
index 0000000..696a4c0
--- /dev/null
+++ b/ext/pcre/tests/study.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Study regex
+--FILE--
+<?php
+
+var_dump(preg_match('/(?:(?:(?:(?:(?:(.))))))/ S', 'aeiou', $dump));
+var_dump($dump[1]);
+var_dump(preg_match('/(?:(?:(?:(?:(?:(.))))))/', 'aeiou', $dump));
+var_dump($dump[1]);
+
+var_dump(preg_match('/(?>..)((?:(?>.)|.|.|.|u))/S', 'aeiou', $dump));
+var_dump($dump[1]);
+
+// try to trigger usual "match known text" optimization
+var_dump(preg_match('/^aeiou$/S', 'aeiou', $dump));
+var_dump($dump[0]);
+var_dump(preg_match('/aeiou/S', 'aeiou', $dump));
+var_dump($dump[0]);
+
+?>
+--EXPECT--
+int(1)
+string(1) "a"
+int(1)
+string(1) "a"
+int(1)
+string(1) "i"
+int(1)
+string(5) "aeiou"
+int(1)
+string(5) "aeiou"
diff --git a/ext/pcre/tests/ungreedy.phpt b/ext/pcre/tests/ungreedy.phpt
new file mode 100644
index 0000000..cf5e8ad
--- /dev/null
+++ b/ext/pcre/tests/ungreedy.phpt
@@ -0,0 +1,31 @@
+--TEST--
+U (PCRE_UNGREEDY) modififer
+--FILE--
+<?php
+
+var_dump(preg_match('/<.*>/', '<aa> <bb> <cc>', $m));
+var_dump($m);
+
+var_dump(preg_match('/<.*>/U', '<aa> <bb> <cc>', $m));
+var_dump($m);
+
+var_dump(preg_match('/(?U)<.*>/', '<aa> <bb> <cc>', $m));
+var_dump($m);
+
+?>
+--EXPECT--
+int(1)
+array(1) {
+ [0]=>
+ string(14) "<aa> <bb> <cc>"
+}
+int(1)
+array(1) {
+ [0]=>
+ string(4) "<aa>"
+}
+int(1)
+array(1) {
+ [0]=>
+ string(4) "<aa>"
+}