shire Sat Dec 27 05:13:30 2008 UTC
Modified files:
/php-src/ext/standard string.c
/php-src/ext/standard/tests/strings explode.phpt
Log:
fix explode behavior to respect negative limit when string is empty.
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.686&r2=1.687&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.686 php-src/ext/standard/string.c:1.687
--- php-src/ext/standard/string.c:1.686 Mon Nov 24 19:31:02 2008
+++ php-src/ext/standard/string.c Sat Dec 27 05:13:29 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.686 2008/11/24 19:31:02 lbarnaud Exp $ */
+/* $Id: string.c,v 1.687 2008/12/27 05:13:29 shire Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -1294,10 +1294,12 @@
array_init(return_value);
if ( str_len == 0 ) {
- if ( str_type == IS_UNICODE ) {
- add_next_index_unicodel(return_value, USTR_MAKE(""),
sizeof("")-1, 0);
- } else {
- add_next_index_stringl(return_value, "", sizeof("")-1,
1);
+ if (limit >= 0 || argc == 2) {
+ if ( str_type == IS_UNICODE ) {
+ add_next_index_unicodel(return_value,
USTR_MAKE(""), sizeof("")-1, 0);
+ } else {
+ add_next_index_stringl(return_value, "",
sizeof("")-1, 1);
+ }
}
return;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/explode.phpt?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/standard/tests/strings/explode.phpt
diff -u php-src/ext/standard/tests/strings/explode.phpt:1.9
php-src/ext/standard/tests/strings/explode.phpt:1.10
--- php-src/ext/standard/tests/strings/explode.phpt:1.9 Tue May 27 10:50:45 2008
+++ php-src/ext/standard/tests/strings/explode.phpt Sat Dec 27 05:13:30 2008
@@ -18,6 +18,7 @@
var_dump(@explode(NULL, a));
var_dump(@explode("abc", "acb"));
var_dump(@explode("somestring", "otherstring"));
+var_dump(@explode("somestring", "otherstring", -1));
var_dump(@explode("a", "aaaaaa"));
var_dump(@explode("==", str_repeat("-=".ord(0)."=-", 10)));
var_dump(@explode("=", str_repeat("-=".ord(0)."=-", 10)));
@@ -64,6 +65,8 @@
[0]=>
unicode(11) "otherstring"
}
+array(0) {
+}
array(7) {
[0]=>
unicode(0) ""
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php