nlopess Sun Jan 13 14:57:54 2008 UTC
Modified files:
/php-src/ext/pcre php_pcre.c
/php-src/ext/pcre/tests bug42945.phpt
Log:
MFB: fix bug #42945
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.227&r2=1.228&diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.227 php-src/ext/pcre/php_pcre.c:1.228
--- php-src/ext/pcre/php_pcre.c:1.227 Mon Dec 31 07:12:12 2007
+++ php-src/ext/pcre/php_pcre.c Sun Jan 13 14:57:53 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.227 2007/12/31 07:12:12 sebastian Exp $ */
+/* $Id: php_pcre.c,v 1.228 2008/01/13 14:57:53 nlopess Exp $ */
/* TODO
* php_pcre_replace_impl():
@@ -1747,7 +1747,9 @@
}
- if (!no_empty || start_offset != subject_len)
+ start_offset = last_match - subject; /* the offset might have been
incremented, but without further successful matches */
+
+ if (!no_empty || start_offset < subject_len)
{
if (offset_capture) {
/* Add the last (match, offset) pair to the return
value */
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/bug42945.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/pcre/tests/bug42945.phpt
diff -u /dev/null php-src/ext/pcre/tests/bug42945.phpt:1.2
--- /dev/null Sun Jan 13 14:57:54 2008
+++ php-src/ext/pcre/tests/bug42945.phpt Sun Jan 13 14:57:54 2008
@@ -0,0 +1,162 @@
+--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)
+ }
+}
+--UEXPECT--
+int(2)
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ unicode(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ unicode(0) ""
+ [1]=>
+ int(1)
+ }
+ }
+}
+array(3) {
+ [0]=>
+ unicode(0) ""
+ [1]=>
+ unicode(1) "a"
+ [2]=>
+ unicode(1) "'"
+}
+array(3) {
+ [0]=>
+ array(2) {
+ [0]=>
+ unicode(0) ""
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ unicode(1) "a"
+ [1]=>
+ int(0)
+ }
+ [2]=>
+ array(2) {
+ [0]=>
+ unicode(1) "'"
+ [1]=>
+ int(1)
+ }
+}
+array(2) {
+ [0]=>
+ unicode(1) "a"
+ [1]=>
+ unicode(1) "'"
+}
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ unicode(1) "a"
+ [1]=>
+ int(0)
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ unicode(1) "'"
+ [1]=>
+ int(1)
+ }
+}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php