From: Rasmus Lerdorf Date: Tue, 21 Jul 2009 21:15:48 +0000 (+0000) Subject: Fix bug #49003 by tweaking the fix to bug #44929 slightly. X-Git-Tag: php-5.4.0alpha1~191^2~3022 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c74b341cc62f13b5e081a1f3446581faf51c8986;p=php 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. --- diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c index c03517e659..569e02ddf5 100644 --- a/ext/standard/strnatcmp.c +++ b/ext/standard/strnatcmp.c @@ -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 */ diff --git a/ext/standard/tests/array/bug44929.phpt b/ext/standard/tests/array/bug44929.phpt index f82ecd0526..9dc85acd1f 100644 --- a/ext/standard/tests/array/bug44929.phpt +++ b/ext/standard/tests/array/bug44929.phpt @@ -2,20 +2,24 @@ Bug #44929 (natsort doesn't handle leading zeros well) --FILE-- --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]=>