cvs: php4 /ext/pcre php_pcre.c

From: Date: Fri, 04 May 2001 16:43:53 +0000
Subject: cvs: php4 /ext/pcre php_pcre.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5527@lists.php.net to get a copy of this message
andrei Fri May 4 09:43:53 2001 EDT Modified files: /php4/ext/pcre php_pcre.c Log: @- Fixed a bug in preg_split() that would incorrectly limit the number of @ results when used along with PREG_SPLIT_NO_EMPTY flag. (Andrei) - Fixed a bug in preg_split() that would incorrectly limit the number of results when used along with PREG_SPLIT_NO_EMPTY flag. (Andrei) - Also made limit = -1 when limit = 0, to emulate Perl. Index: php4/ext/pcre/php_pcre.c diff -u php4/ext/pcre/php_pcre.c:1.92 php4/ext/pcre/php_pcre.c:1.93 --- php4/ext/pcre/php_pcre.c:1.92 Sun Apr 22 10:20:03 2001 +++ php4/ext/pcre/php_pcre.c Fri May 4 09:43:53 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.c,v 1.92 2001/04/22 17:20:03 sas Exp $ */ +/* $Id: php_pcre.c,v 1.93 2001/05/04 16:43:53 andrei Exp $ */ #include "php.h" #include "php_globals.h" @@ -1085,6 +1085,8 @@ if (argc > 2) { convert_to_long_ex(limit); limit_val = Z_LVAL_PP(limit); + if (limit_val == 0) + limit_val = -1; if (argc > 3) { convert_to_long_ex(flags); @@ -1130,10 +1132,15 @@ if (count > 0) { match = Z_STRVAL_PP(subject) + offsets[0]; - if (!no_empty || &Z_STRVAL_PP(subject)[offsets[0]] != last_match) + if (!no_empty || &Z_STRVAL_PP(subject)[offsets[0]] != last_match) { /* Add the piece to the return value */ add_next_index_stringl(return_value, last_match, &Z_STRVAL_PP(subject)[offsets[0]]-last_match, 1); + + /* One less left to do */ + if (limit_val != -1) + limit_val--; + } last_match = &Z_STRVAL_PP(subject)[offsets[1]]; @@ -1147,10 +1154,6 @@ match_len, 1); } } - - /* One less left to do */ - if (limit_val != -1) - limit_val--; } else { /* Failed to match */ /* If we previously set PCRE_NOTEMPTY after a null match, this is not necessarily the end. We need to advance

« previous php.cvs (#5527) next »