From c3ed91477a011e494559d6f65301ef6b2e38cd22 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 15 Jun 2006 15:33:25 +0000 Subject: fix bug #37800: preg_replace() limit parameter odd behaviour #this is a regression in PHP_5_2 and HEAD branches only --- ext/pcre/php_pcre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/pcre/php_pcre.c') diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 58225eb09e..e4dee71d4c 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1091,7 +1091,7 @@ PHPAPI char *php_pcre_replace(char *regex, int regex_len, 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 -- cgit v1.2.1