]> granicus.if.org Git - php/commitdiff
Fix bug #49003 by tweaking the fix to bug #44929 slightly.
authorRasmus Lerdorf <rasmus@php.net>
Tue, 21 Jul 2009 21:15:48 +0000 (21:15 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Tue, 21 Jul 2009 21:15:48 +0000 (21:15 +0000)
A 0 followed by any punctuation is now significant instead
of just 0's in front of a period.

ext/standard/strnatcmp.c
ext/standard/tests/array/bug44929.phpt

index 366c12449fd765521daf2d17060385628ab36a5d..c3a8a820101083b1c92498a0fe149eca572cdacb 100644 (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 */
index f82ecd05261b1ff31aa2aeaf79c97ed9827060cb..9dc85acd1f1093f2c6c702ee47da5f82e9ba56e7 100644 (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]=>