mirror of
https://github.com/php/php-src.git
synced 2026-04-29 19:23:22 +02:00
Don't strip leading zeros on floating point numbers
and fix the test case
This commit is contained in:
@@ -112,10 +112,10 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len
|
||||
ca = a[ai]; cb = b[bi];
|
||||
|
||||
/* skip over leading spaces or zeros */
|
||||
while (isspace((int)(unsigned char)ca) || (ca == '0' && ai+1 < a_len))
|
||||
while (isspace((int)(unsigned char)ca) || (ca == '0' && (ai+1 < a_len)) && (a[ai+1] != '.'))
|
||||
ca = a[++ai];
|
||||
|
||||
while (isspace((int)(unsigned char)cb) || (cb == '0' && bi+1 < b_len))
|
||||
while (isspace((int)(unsigned char)cb) || (cb == '0' && bi+1 < b_len) && (b[bi+1] != '.'))
|
||||
cb = b[++bi];
|
||||
|
||||
/* process run of digits */
|
||||
|
||||
@@ -10,12 +10,12 @@ var_dump($a);
|
||||
array(10) {
|
||||
[6]=>
|
||||
string(4) "-123"
|
||||
[7]=>
|
||||
string(5) "0.002"
|
||||
[8]=>
|
||||
string(2) "00"
|
||||
[9]=>
|
||||
string(1) "0"
|
||||
[7]=>
|
||||
string(5) "0.002"
|
||||
[0]=>
|
||||
string(3) "001"
|
||||
[4]=>
|
||||
|
||||
Reference in New Issue
Block a user