cvs: php4 /ext/standard/ string.c

[email protected] ("Andrei Zmievski")
Newsgroups php.version4
Message-ID <cvsandrei959085492@cvsserver>
andrei		Tue May 23 14:38:12 2000 EDT

  Modified files:
    /php4/ext/standard	string.c 
  Log:
  Clean up the patch by Hartmut.
  
  
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.113 php4/ext/standard/string.c:1.114
--- php4/ext/standard/string.c:1.113	Tue May 23 07:04:28 2000
+++ php4/ext/standard/string.c	Tue May 23 14:38:12 2000
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c,v 1.113 2000/05/23 05:04:28 hholzgra Exp $ */
+/* $Id: string.c,v 1.114 2000/05/23 12:38:12 andrei Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -216,7 +216,6 @@
 PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, int limit) 
 {
 	char *p1, *p2, *endp;
-	int i = 0;
 
 	endp = str->value.str.val + str->value.str.len;
 
@@ -224,18 +223,16 @@
 	p2 = php_memnstr(str->value.str.val, delim->value.str.val, delim->value.str.len, endp);
 
 	if (p2 == NULL) {
-		add_index_stringl(return_value, i++, p1, str->value.str.len, 1);
+		add_next_index_stringl(return_value, p1, str->value.str.len, 1);
 	} else {
 		do {
-			add_index_stringl(return_value, i++, p1, p2-p1, 1);
+			add_next_index_stringl(return_value, p1, p2-p1, 1);
 			p1 = p2 + delim->value.str.len;
-			if((limit>=0)&&(i>=limit-1))
-				break;
-		} while ((p2 = php_memnstr(p1, delim->value.str.val, delim->value.str.len, endp)) != NULL);
+		} while ((p2 = php_memnstr(p1, delim->value.str.val, delim->value.str.len, endp)) != NULL &&
+				 (limit == -1 || --limit > 1));
 
-		if ((p1 <= endp)|| ((limit>=0)&&(i>=limit-1))){
-			add_index_stringl(return_value, i++, p1, endp-p1, 1);
-		}
+		if (p1 <= endp)
+			add_next_index_stringl(return_value, p1, endp-p1, 1);
 	}
 }
 
@@ -274,7 +271,7 @@
 		RETURN_FALSE;
 	}
 
-	if((limit==0)||(limit==1)) {
+	if(limit==0 || limit==1) {
 		add_index_stringl(return_value, 0, (*str)->value.str.val, (*str)->value.str.len, 1);
 	} else {
 		php_explode(*delim, *str, return_value, limit);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.