Fix bug #49003 by tweaking the fix to bug #44929 slightly.

A 0 followed by any punctuation is now significant instead
of just 0's in front of a period.
This commit is contained in:
Rasmus Lerdorf 2009-07-21 21:15:48 +00:00
parent 27dccf7ac0
commit 7bba051009
2 changed files with 8 additions and 4 deletions

View File

@ -116,10 +116,10 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len
ca = *ap; cb = *bp;
/* skip over leading spaces or zeros */
while (isspace((int)(unsigned char)ca) || (ca == '0' && (ap+1 < aend) && (*(ap+1)!='.')))
while (isspace((int)(unsigned char)ca) || (ca == '0' && (ap+1 < aend) && !ispunct(*(ap+1))))
ca = *++ap;
while (isspace((int)(unsigned char)cb) || (cb == '0' && (bp+1 < bend) && (*(bp+1)!='.')))
while (isspace((int)(unsigned char)cb) || (cb == '0' && (bp+1 < bend) && !ispunct(*(bp+1))))
cb = *++bp;
/* process run of digits */

View File

@ -2,20 +2,24 @@
Bug #44929 (natsort doesn't handle leading zeros well)
--FILE--
<?php
$a = array(b'001',b'008',b'005',b'00011',b'03',b'000014',b'-123',b'0.002',b'00',b'0');
$a = array(b'001',b'008',b'005',b'00011',b'03',b'000014',b'-123',b'0.002',b'00',b'0',b'0_0',b'0-0');
natsort($a);
var_dump($a);
?>
--EXPECT--
array(10) {
array(12) {
[6]=>
string(4) "-123"
[8]=>
string(2) "00"
[9]=>
string(1) "0"
[11]=>
string(3) "0-0"
[7]=>
string(5) "0.002"
[10]=>
string(3) "0_0"
[0]=>
string(3) "001"
[4]=>