CVS update: php3/functions
| From: | zeev | Date: | Sun, 30 Aug 1998 19:42:04 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-678@lists.php.net to get a copy of this message | ||
Date: Sunday August 30, 1998 @ 15:42
Author: zeev
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv26567/functions
Modified Files:
string.c
Log Message:
Fix for #706
Index: php3/functions/string.c
diff -c php3/functions/string.c:1.134 php3/functions/string.c:1.135
*** php3/functions/string.c:1.134 Tue Aug 4 09:32:10 1998
--- php3/functions/string.c Sun Aug 30 15:42:03 1998
***************
*** 30,36 ****
*/
! /* $Id: string.c,v 1.134 1998/08/04 13:32:10 rasmus Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 30,36 ----
*/
! /* $Id: string.c,v 1.135 1998/08/30 19:42:03 zeev Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 215,238 ****
convert_to_string(str);
convert_to_string(delim);
! if (str->type == IS_STRING && delim->type == IS_STRING) {
! if (array_init(return_value) == FAILURE) {
! return;
! }
! work_str = p1 = estrndup(str->value.str.val,str->value.str.len);
! p2 = strstr(p1, delim->value.str.val);
! if (p2 == NULL) {
! add_index_string(return_value, i++, p1, 1);
! } else do {
! p2[0] = 0;
! add_index_string(return_value, i++, p1, 1);
! p1 = p2 + delim->value.str.len;
! } while ((p2 = strstr(p1, delim->value.str.val)) && p2 != work_str);
! if (p1 != work_str) {
! add_index_string(return_value, i++, p1, 1);
! }
! efree(work_str);
}
}
--- 215,241 ----
convert_to_string(str);
convert_to_string(delim);
! if (strlen(delim->value.str.val)==0) {
! /* the delimiter must be a valid C string that's at least 1 character long */
! php3_error(E_WARNING,"Empty delimiter");
! RETURN_FALSE;
! }
! if (array_init(return_value) == FAILURE) {
! return;
}
+ work_str = p1 = estrndup(str->value.str.val,str->value.str.len);
+ p2 = strstr(p1, delim->value.str.val);
+ if (p2 == NULL) {
+ add_index_string(return_value, i++, p1, 1);
+ } else do {
+ p2[0] = 0;
+ add_index_string(return_value, i++, p1, 1);
+ p1 = p2 + delim->value.str.len;
+ } while ((p2 = strstr(p1, delim->value.str.val)) && p2 != work_str);
+ if (p1 != work_str) {
+ add_index_string(return_value, i++, p1, 1);
+ }
+ efree(work_str);
}
***************
*** 485,490 ****
--- 488,497 ----
convert_to_string(haystack);
if (needle->type == IS_STRING) {
+ if (strlen(needle->value.str.val)==0) {
+ php3_error(E_WARNING,"Empty delimiter");
+ RETURN_FALSE;
+ }
found = strstr(haystack->value.str.val, needle->value.str.val);
} else {
convert_to_long(needle);
***************
*** 511,516 ****
--- 518,527 ----
convert_to_string(haystack);
if (needle->type == IS_STRING) {
+ if (strlen(needle->value.str.val)==0) {
+ php3_error(E_WARNING,"Empty delimiter");
+ RETURN_FALSE;
+ }
found = strstr(haystack->value.str.val, needle->value.str.val);
} else {
convert_to_long(needle);
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net