cvs: /php4 TODO /php4/ext/standard string.c

From: Date: Sat, 11 Dec 1999 20:01:11 +0000
Subject: cvs: /php4 TODO /php4/ext/standard string.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-7800@lists.php.net to get a copy of this message
andrei Sat Dec 11 15:01:11 1999 EDT Modified files: /php4 TODO /php4/ext/standard string.c Log: (PHP php_implode) Made binary-safe. @ Made implode() binary-safe (Andrei) Index: php4/TODO diff -u php4/TODO:1.15 php4/TODO:1.16 --- php4/TODO:1.15 Sat Dec 11 14:50:00 1999 +++ php4/TODO Sat Dec 11 15:00:40 1999 @@ -27,7 +27,6 @@ * advanced sort (Andrei) * NOT binary safe: strcspn() - implode() strtok() basename() dirname() Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.70 php4/ext/standard/string.c:1.71 --- php4/ext/standard/string.c:1.70 Sat Dec 11 14:50:01 1999 +++ php4/ext/standard/string.c Sat Dec 11 15:00:40 1999 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.70 1999/12/11 19:50:01 andrei Exp $ */ +/* $Id: string.c,v 1.71 1999/12/11 20:00:40 andrei Exp $ */ /* Synced with php3 revision 1.193 1999-06-16 [ssb] */ @@ -265,19 +265,17 @@ PHPAPI void php_implode(pval *delim, pval *arr, pval *return_value) { pval **tmp; - int len = 0, count = 0; + int len = 0, count = 0, target = 0; /* convert everything to strings, and calculate length */ zend_hash_internal_pointer_reset(arr->value.ht); while (zend_hash_get_current_data(arr->value.ht, (void **) &tmp) == SUCCESS) { convert_to_string_ex(tmp); - if ((*tmp)->type == IS_STRING && (*tmp)->value.str.val != undefined_variable_string) { - len += (*tmp)->value.str.len; - if (count>0) { - len += delim->value.str.len; - } - count++; + len += (*tmp)->value.str.len; + if (count>0) { + len += delim->value.str.len; } + count++; zend_hash_move_forward(arr->value.ht); } @@ -287,12 +285,14 @@ return_value->value.str.val[len] = '\0'; zend_hash_internal_pointer_reset(arr->value.ht); while (zend_hash_get_current_data(arr->value.ht, (void **) &tmp) == SUCCESS) { - if ((*tmp)->type == IS_STRING && (*tmp)->value.str.val != undefined_variable_string) { - count--; - strcat(return_value->value.str.val, (*tmp)->value.str.val); - if (count > 0) { - strcat(return_value->value.str.val, delim->value.str.val); - } + count--; + memcpy(return_value->value.str.val + target, (*tmp)->value.str.val, + (*tmp)->value.str.len); + target += (*tmp)->value.str.len; + if (count > 0) { + memcpy(return_value->value.str.val + target, delim->value.str.val, + delim->value.str.len); + target += delim->value.str.len; } zend_hash_move_forward(arr->value.ht); }

« previous php.version4 (#7800) next »