[PHP-CVS] cvs: php-src /ext/standard strnatcmp.c
iliaa Sun Apr 26 15:53:52 2009 UTC Modified files: /php-src/ext/standard strnatcmp.c Log: Fixed compiler warning http://cvs.php.net/viewvc.cgi/php-src/ext/standard/strnatcmp.c?r1=1.15r2=1.16diff_format=u Index: php-src/ext/standard/strnatcmp.c diff -u php-src/ext/standard/strnatcmp.c:1.15 php-src/ext/standard/strnatcmp.c:1.16 --- php-src/ext/standard/strnatcmp.c:1.15 Thu Apr 9 16:08:34 2009 +++ php-src/ext/standard/strnatcmp.cSun Apr 26 15:53:52 2009 @@ -38,7 +38,7 @@ #if 0 static char const *version UNUSED = -$Id: strnatcmp.c,v 1.15 2009/04/09 16:08:34 rasmus Exp $; +$Id: strnatcmp.c,v 1.16 2009/04/26 15:53:52 iliaa Exp $; #endif /* {{{ compare_right */ @@ -112,10 +112,10 @@ 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)) (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) (b[bi+1] != '.'))) cb = b[++bi]; /* process run of digits */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard strnatcmp.c /ext/standard/tests/array bug44929.phpt
rasmus Wed Apr 8 18:18:49 2009 UTC Modified files: /php-src/ext/standard strnatcmp.c /php-src/ext/standard/tests/array bug44929.phpt Log: Fixed bug #44929 - Better handling of leading zeros This is obviously not going to work for Unicode strings, but the whole function needs to be rewritten, so keep it in synch with the other branches for now. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/strnatcmp.c?r1=1.12r2=1.13diff_format=u Index: php-src/ext/standard/strnatcmp.c diff -u php-src/ext/standard/strnatcmp.c:1.12 php-src/ext/standard/strnatcmp.c:1.13 --- php-src/ext/standard/strnatcmp.c:1.12 Mon Jan 1 09:29:32 2007 +++ php-src/ext/standard/strnatcmp.cWed Apr 8 18:18:49 2009 @@ -38,7 +38,7 @@ #if 0 static char const *version UNUSED = -$Id: strnatcmp.c,v 1.12 2007/01/01 09:29:32 sebastian Exp $; +$Id: strnatcmp.c,v 1.13 2009/04/08 18:18:49 rasmus Exp $; #endif /* {{{ compare_right */ @@ -112,10 +112,10 @@ ca = a[ai]; cb = b[bi]; /* skip over leading spaces or zeros */ - while (isspace((int)(unsigned char)ca)) + while (isspace((int)(unsigned char)ca) || (ca == '0' ap+1 aend)) ca = a[++ai]; - while (isspace((int)(unsigned char)cb)) + while (isspace((int)(unsigned char)cb) || (cb == '0' bp+1 bend)) cb = b[++bi]; /* process run of digits */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug44929.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/array/bug44929.phpt diff -u /dev/null php-src/ext/standard/tests/array/bug44929.phpt:1.2 --- /dev/null Wed Apr 8 18:18:49 2009 +++ php-src/ext/standard/tests/array/bug44929.phpt Wed Apr 8 18:18:49 2009 @@ -0,0 +1,31 @@ +--TEST-- +Bug #44929 (natsort doesn't handle leading zeros well) +--FILE-- +?php +$a = array('001','008','005','00011','03','14','-123','0.002','00','0'); +natsort($a); +var_dump($a); +? +--EXPECT-- +array(10) { + [6]= + string(4) -123 + [7]= + string(5) 0.002 + [8]= + string(2) 00 + [9]= + string(1) 0 + [0]= + string(3) 001 + [4]= + string(2) 03 + [2]= + string(3) 005 + [1]= + string(3) 008 + [3]= + string(5) 00011 + [5]= + string(6) 14 +} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard strnatcmp.c
andrei Wed Apr 8 20:12:28 2009 UTC Modified files: /php-src/ext/standard strnatcmp.c Log: Fix Rasmus's patch for bug #44929. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/strnatcmp.c?r1=1.13r2=1.14diff_format=u Index: php-src/ext/standard/strnatcmp.c diff -u php-src/ext/standard/strnatcmp.c:1.13 php-src/ext/standard/strnatcmp.c:1.14 --- php-src/ext/standard/strnatcmp.c:1.13 Wed Apr 8 18:18:49 2009 +++ php-src/ext/standard/strnatcmp.cWed Apr 8 20:12:27 2009 @@ -38,7 +38,7 @@ #if 0 static char const *version UNUSED = -$Id: strnatcmp.c,v 1.13 2009/04/08 18:18:49 rasmus Exp $; +$Id: strnatcmp.c,v 1.14 2009/04/08 20:12:27 andrei Exp $; #endif /* {{{ compare_right */ @@ -112,10 +112,10 @@ ca = a[ai]; cb = b[bi]; /* skip over leading spaces or zeros */ - while (isspace((int)(unsigned char)ca) || (ca == '0' ap+1 aend)) + while (isspace((int)(unsigned char)ca) || (ca == '0' ai+1 a_len)) ca = a[++ai]; - while (isspace((int)(unsigned char)cb) || (cb == '0' bp+1 bend)) + while (isspace((int)(unsigned char)cb) || (cb == '0' bi+1 b_len)) cb = b[++bi]; /* process run of digits */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php