]> 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 c03517e659e83d08dbab537928db4690c399535a..569e02ddf5f7ac8a90f8ee4930c8554875069cca 100644 (file)
@@ -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)) && (a[ai+1] != '.')))
+               while (isspace((int)(unsigned char)ca) || ((ca == '0' && (ai+1 < a_len)) && !ispunct(a[ai+1])))
                        ca = a[++ai];
 
-               while (isspace((int)(unsigned char)cb) || ((cb == '0' && bi+1 < b_len) && (b[bi+1] != '.')))
+               while (isspace((int)(unsigned char)cb) || ((cb == '0' && bi+1 < b_len) && !ispunct(b[bi+1])))
                        cb = b[++bi];
 
                /* 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]=>