com php-src: Ran wrong tests, fixed bug in impl; simplified: ext/standard/string.c

From: Date: Mon, 25 May 2015 23:43:56 +0000
Subject: com php-src: Ran wrong tests, fixed bug in impl; simplified: ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86930@lists.php.net to get a copy of this message
Commit: 1a7bf16dd6299bf6a5745f28edf50a44dc83dba2 Author: Bob Weinand <bobwei9@hotmail.com> Tue, 26 May 2015 01:43:56 +0200 Parents: bb552908a05ba26c2a12cc111a4cdab6a53a4c31 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1a7bf16dd6299bf6a5745f28edf50a44dc83dba2 Log: Ran wrong tests, fixed bug in impl; simplified Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index 7dad1b6...8d95290 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1223,9 +1223,17 @@ PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value) ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), tmp) { if (Z_TYPE_P(tmp) == IS_LONG) { + double val = Z_LVAL_P(tmp); *++strptr = NULL; ((zend_long *) (strings + numelems))[strptr - strings] = Z_LVAL_P(tmp); - len += (int) log10(Z_LVAL_P(tmp) < 0 ? -100 * ((double) Z_LVAL_P(tmp) - 0.001) : 10 * ((double) Z_LVAL_P(tmp) + 0.01)); + if (val < 0) { + val = -10 * val; + } + if (val < 10) { + len++; + } else { + len += (int) log10(10 * (double) val); + } } else { *++strptr = zval_get_string(tmp); len += (*strptr)->len;

« previous php.cvs (#86930) next »