nlopess         Thu Jun 15 15:35:50 2006 UTC

  Modified files:              
    /php-src/ext/pcre   php_pcre.c 
    /php-src/ext/pcre/tests     bug37800.phpt 
  Log:
  MFB: fix bug #37800
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/php_pcre.c?r1=1.185&r2=1.186&diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.185 php-src/ext/pcre/php_pcre.c:1.186
--- php-src/ext/pcre/php_pcre.c:1.185   Wed Jun 14 18:04:01 2006
+++ php-src/ext/pcre/php_pcre.c Thu Jun 15 15:35:49 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.185 2006/06/14 18:04:01 nlopess Exp $ */
+/* $Id: php_pcre.c,v 1.186 2006/06/15 15:35:49 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1083,7 +1083,7 @@
                        if (limit != -1)
                                limit--;
 
-               } else if (count == PCRE_ERROR_NOMATCH) {
+               } else if (count == PCRE_ERROR_NOMATCH || limit == 0) {
                        /* If we previously set PCRE_NOTEMPTY after a null 
match,
                           this is not necessarily the end. We need to advance
                           the start offset, and continue. Fudge the offset 
values
http://cvs.php.net/viewcvs.cgi/php-src/ext/pcre/tests/bug37800.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/pcre/tests/bug37800.phpt
diff -u /dev/null php-src/ext/pcre/tests/bug37800.phpt:1.2
--- /dev/null   Thu Jun 15 15:35:50 2006
+++ php-src/ext/pcre/tests/bug37800.phpt        Thu Jun 15 15:35:50 2006
@@ -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)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to