Re: [PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/ext/standard/strnatcmp.c branches/PHP_5_3/ext/standard/strnatcmp.c trunk/ext/standard/strnatcmp.c
Could you add some test for this bug too? --Jani On 09/28/2009 04:29 PM, Rasmus Lerdorf wrote: rasmus Mon, 28 Sep 2009 13:29:53 + Revision: http://svn.php.net/viewvc?view=revisionrevision=288896 Log: Fix for bug #49698 Bug: http://bugs.php.net/49698 (Open) Unexpected change in strnatcasecmp() Changed paths: U php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c U php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c U php/php-src/trunk/ext/standard/strnatcmp.c Modified: php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-09-28 13:11:21 UTC (rev 288895) +++ php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-09-28 13:29:53 UTC (rev 288896) @@ -116,12 +116,12 @@ while (1) { ca = *ap; cb = *bp; - /* skip over leading zeros unless they are followed by punctuation */ - while (leading ca == '0' (ap+1 aend) !ispunct(*(ap+1))) { + /* skip over leading zeros */ + while (leading ca == '0' (ap+1 aend) isdigit(*(ap+1))) { ca = *++ap; } - while (leading cb == '0' (bp+1 bend) !ispunct(*(bp+1))) { + while (leading cb == '0' (bp+1 bend) isdigit(*(bp+1))) { cb = *++bp; } Modified: php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-09-28 13:11:21 UTC (rev 288895) +++ php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-09-28 13:29:53 UTC (rev 288896) @@ -116,12 +116,12 @@ while (1) { ca = *ap; cb = *bp; - /* skip over leading zeros unless they are followed by punctuation */ - while (leading ca == '0' (ap+1 aend) !ispunct(*(ap+1))) { + /* skip over leading zeros */ + while (leading ca == '0' (ap+1 aend) isdigit(*(ap+1))) { ca = *++ap; } - while (leading cb == '0' (bp+1 bend) !ispunct(*(bp+1))) { + while (leading cb == '0' (bp+1 bend) isdigit(*(bp+1))) { cb = *++bp; } Modified: php/php-src/trunk/ext/standard/strnatcmp.c === --- php/php-src/trunk/ext/standard/strnatcmp.c 2009-09-28 13:11:21 UTC (rev 288895) +++ php/php-src/trunk/ext/standard/strnatcmp.c 2009-09-28 13:29:53 UTC (rev 288896) @@ -112,12 +112,12 @@ while (1) { ca = a[ai]; cb = b[bi]; - /* skip over leading zeros unless they are followed by punctuation */ - while (leading ca == '0' (ai+1 a_len) !ispunct(a[ai+1])) { + /* skip over leading zeros */ + while (leading ca == '0' (ai+1 a_len) isdigit(a[ai+1])) { ca = a[++ai]; } - while (leading cb == '0' (bi+1 b_len) !ispunct(b[bi+1])) { + while (leading cb == '0' (bi+1 b_len) isdigit(a[ai+1])) { cb = b[++bi]; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/ext/standard/strnatcmp.c branches/PHP_5_3/ext/standard/strnatcmp.c trunk/ext/standard/strnatcmp.c
rasmus Mon, 28 Sep 2009 13:29:53 + Revision: http://svn.php.net/viewvc?view=revisionrevision=288896 Log: Fix for bug #49698 Bug: http://bugs.php.net/49698 (Open) Unexpected change in strnatcasecmp() Changed paths: U php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c U php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c U php/php-src/trunk/ext/standard/strnatcmp.c Modified: php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-09-28 13:11:21 UTC (rev 288895) +++ php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-09-28 13:29:53 UTC (rev 288896) @@ -116,12 +116,12 @@ while (1) { ca = *ap; cb = *bp; - /* skip over leading zeros unless they are followed by punctuation */ - while (leading ca == '0' (ap+1 aend) !ispunct(*(ap+1))) { + /* skip over leading zeros */ + while (leading ca == '0' (ap+1 aend) isdigit(*(ap+1))) { ca = *++ap; } - while (leading cb == '0' (bp+1 bend) !ispunct(*(bp+1))) { + while (leading cb == '0' (bp+1 bend) isdigit(*(bp+1))) { cb = *++bp; } Modified: php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-09-28 13:11:21 UTC (rev 288895) +++ php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-09-28 13:29:53 UTC (rev 288896) @@ -116,12 +116,12 @@ while (1) { ca = *ap; cb = *bp; - /* skip over leading zeros unless they are followed by punctuation */ - while (leading ca == '0' (ap+1 aend) !ispunct(*(ap+1))) { + /* skip over leading zeros */ + while (leading ca == '0' (ap+1 aend) isdigit(*(ap+1))) { ca = *++ap; } - while (leading cb == '0' (bp+1 bend) !ispunct(*(bp+1))) { + while (leading cb == '0' (bp+1 bend) isdigit(*(bp+1))) { cb = *++bp; } Modified: php/php-src/trunk/ext/standard/strnatcmp.c === --- php/php-src/trunk/ext/standard/strnatcmp.c 2009-09-28 13:11:21 UTC (rev 288895) +++ php/php-src/trunk/ext/standard/strnatcmp.c 2009-09-28 13:29:53 UTC (rev 288896) @@ -112,12 +112,12 @@ while (1) { ca = a[ai]; cb = b[bi]; - /* skip over leading zeros unless they are followed by punctuation */ - while (leading ca == '0' (ai+1 a_len) !ispunct(a[ai+1])) { + /* skip over leading zeros */ + while (leading ca == '0' (ai+1 a_len) isdigit(a[ai+1])) { ca = a[++ai]; } - while (leading cb == '0' (bi+1 b_len) !ispunct(b[bi+1])) { + while (leading cb == '0' (bi+1 b_len) isdigit(a[ai+1])) { cb = b[++bi]; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/ext/standard/strnatcmp.c branches/PHP_5_3/ext/standard/strnatcmp.c trunk/ext/standard/strnatcmp.c
rasmus Sat, 08 Aug 2009 14:39:34 + Revision: http://svn.php.net/viewvc?view=revisionrevision=286930 Log: Restore intra-string whitespace collapsing broken in the previous change. Changed paths: U php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c U php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c U php/php-src/trunk/ext/standard/strnatcmp.c Modified: php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-08-08 13:01:13 UTC (rev 286929) +++ php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-08-08 14:39:34 UTC (rev 286930) @@ -116,17 +116,26 @@ while (1) { ca = *ap; cb = *bp; - /* skip over leading spaces or zeros */ - while (leading (isspace((int)(unsigned char)ca) || (ca == '0' (ap+1 aend) !ispunct(*(ap+1) { + /* skip over leading zeros unless they are followed by punctuation */ + while (leading ca == '0' (ap+1 aend) !ispunct(*(ap+1))) { ca = *++ap; } - while (leading (isspace((int)(unsigned char)cb) || (cb == '0' (bp+1 bend) !ispunct(*(bp+1) { + while (leading cb == '0' (bp+1 bend) !ispunct(*(bp+1))) { cb = *++bp; } leading = 0; + /* Skip consecutive whitespace */ + while (isspace((int)(unsigned char)ca)) { + ca = *++ap; + } + + while (isspace((int)(unsigned char)cb)) { + cb = *++bp; + } + /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { fractional = (ca == '0' || cb == '0'); Modified: php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-08-08 13:01:13 UTC (rev 286929) +++ php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-08-08 14:39:34 UTC (rev 286930) @@ -116,17 +116,26 @@ while (1) { ca = *ap; cb = *bp; - /* skip over leading spaces or zeros */ - while (leading (isspace((int)(unsigned char)ca) || (ca == '0' (ap+1 aend) !ispunct(*(ap+1) { + /* skip over leading zeros unless they are followed by punctuation */ + while (leading ca == '0' (ap+1 aend) !ispunct(*(ap+1))) { ca = *++ap; } - while (leading (isspace((int)(unsigned char)cb) || (cb == '0' (bp+1 bend) !ispunct(*(bp+1) { + while (leading cb == '0' (bp+1 bend) !ispunct(*(bp+1))) { cb = *++bp; } leading = 0; + /* Skip consecutive whitespace */ + while (isspace((int)(unsigned char)ca)) { + ca = *++ap; + } + + while (isspace((int)(unsigned char)cb)) { + cb = *++bp; + } + /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { fractional = (ca == '0' || cb == '0'); Modified: php/php-src/trunk/ext/standard/strnatcmp.c === --- php/php-src/trunk/ext/standard/strnatcmp.c 2009-08-08 13:01:13 UTC (rev 286929) +++ php/php-src/trunk/ext/standard/strnatcmp.c 2009-08-08 14:39:34 UTC (rev 286930) @@ -112,17 +112,26 @@ while (1) { ca = a[ai]; cb = b[bi]; - /* skip over leading spaces or zeros */ - while (leading (isspace((int)(unsigned char)ca) || ((ca == '0' (ai+1 a_len)) !ispunct(a[ai+1] { + /* skip over leading zeros unless they are followed by punctuation */ + while (leading ca == '0' (ai+1 a_len) !ispunct(a[ai+1])) { ca = a[++ai]; } - while (leading (isspace((int)(unsigned char)cb) || ((cb == '0' bi+1 b_len) !ispunct(b[bi+1] { + while (leading cb == '0' (bi+1 b_len) !ispunct(b[bi+1])) { cb = b[++bi]; } leading = 0; + /* Strip consecutive whitespace */ + while (isspace((int)(unsigned char)ca)) { + ca = a[++ai]; + } + + while (isspace((int)(unsigned char)cb)) { + cb = b[++bi]; + } + /* process run of digits */ if (isdigit((int)(unsigned char)ca)
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/ext/standard/strnatcmp.c branches/PHP_5_3/ext/standard/strnatcmp.c trunk/ext/standard/strnatcmp.c
rasmus Fri, 07 Aug 2009 17:14:19 + Revision: http://svn.php.net/viewvc?view=revisionrevision=286915 Log: Only skip leading 0's - fixes a test I broke a while ago Changed paths: U php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c U php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c U php/php-src/trunk/ext/standard/strnatcmp.c Modified: php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-08-07 15:45:56 UTC (rev 286914) +++ php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-08-07 17:14:19 UTC (rev 286915) @@ -105,7 +105,7 @@ char const *ap, *bp; char const *aend = a + a_len, *bend = b + b_len; - int fractional, result; + int fractional, result, leading = true; if (a_len == 0 || b_len == 0) return a_len - b_len; @@ -116,12 +116,16 @@ ca = *ap; cb = *bp; /* skip over leading spaces or zeros */ - while (isspace((int)(unsigned char)ca) || (ca == '0' (ap+1 aend) !ispunct(*(ap+1 + while (leading (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) !ispunct(*(bp+1 + while (leading (isspace((int)(unsigned char)cb) || (cb == '0' (bp+1 bend) !ispunct(*(bp+1) { cb = *++bp; + } + leading = false; + /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { fractional = (ca == '0' || cb == '0'); Modified: php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-08-07 15:45:56 UTC (rev 286914) +++ php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-08-07 17:14:19 UTC (rev 286915) @@ -105,7 +105,7 @@ char const *ap, *bp; char const *aend = a + a_len, *bend = b + b_len; - int fractional, result; + int fractional, result, leading = true; if (a_len == 0 || b_len == 0) return a_len - b_len; @@ -116,12 +116,16 @@ ca = *ap; cb = *bp; /* skip over leading spaces or zeros */ - while (isspace((int)(unsigned char)ca) || (ca == '0' (ap+1 aend) !ispunct(*(ap+1 + while (leading (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) !ispunct(*(bp+1 + while (leading (isspace((int)(unsigned char)cb) || (cb == '0' (bp+1 bend) !ispunct(*(bp+1) { cb = *++bp; + } + leading = false; + /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { fractional = (ca == '0' || cb == '0'); Modified: php/php-src/trunk/ext/standard/strnatcmp.c === --- php/php-src/trunk/ext/standard/strnatcmp.c 2009-08-07 15:45:56 UTC (rev 286914) +++ php/php-src/trunk/ext/standard/strnatcmp.c 2009-08-07 17:14:19 UTC (rev 286915) @@ -105,19 +105,23 @@ { unsigned char ca, cb; unsigned int ai, bi; - int fractional, result; + int fractional, result, leading = true; ai = bi = 0; while (1) { ca = a[ai]; cb = b[bi]; /* skip over leading spaces or zeros */ - while (isspace((int)(unsigned char)ca) || ((ca == '0' (ai+1 a_len)) !ispunct(a[ai+1]))) + while (leading (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) !ispunct(b[bi+1]))) + while (leading (isspace((int)(unsigned char)cb) || ((cb == '0' bi+1 b_len) !ispunct(b[bi+1] { cb = b[++bi]; + } + leading = false; + /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { fractional = (ca == '0' || cb == '0'); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_2/ext/standard/strnatcmp.c branches/PHP_5_3/ext/standard/strnatcmp.c trunk/ext/standard/strnatcmp.c
rasmus Fri, 07 Aug 2009 17:32:31 + Revision: http://svn.php.net/viewvc?view=revisionrevision=286916 Log: Oops, true/false are not defined on Linux. They are on OSX. Changed paths: U php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c U php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c U php/php-src/trunk/ext/standard/strnatcmp.c Modified: php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-08-07 17:14:19 UTC (rev 286915) +++ php/php-src/branches/PHP_5_2/ext/standard/strnatcmp.c 2009-08-07 17:32:31 UTC (rev 286916) @@ -105,7 +105,8 @@ char const *ap, *bp; char const *aend = a + a_len, *bend = b + b_len; - int fractional, result, leading = true; + int fractional, result; + short leading = 1; if (a_len == 0 || b_len == 0) return a_len - b_len; @@ -124,7 +125,7 @@ cb = *++bp; } - leading = false; + leading = 0; /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { Modified: php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c === --- php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-08-07 17:14:19 UTC (rev 286915) +++ php/php-src/branches/PHP_5_3/ext/standard/strnatcmp.c 2009-08-07 17:32:31 UTC (rev 286916) @@ -105,7 +105,8 @@ char const *ap, *bp; char const *aend = a + a_len, *bend = b + b_len; - int fractional, result, leading = true; + int fractional, result; + short leading = 1; if (a_len == 0 || b_len == 0) return a_len - b_len; @@ -124,7 +125,7 @@ cb = *++bp; } - leading = false; + leading = 0; /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { Modified: php/php-src/trunk/ext/standard/strnatcmp.c === --- php/php-src/trunk/ext/standard/strnatcmp.c 2009-08-07 17:14:19 UTC (rev 286915) +++ php/php-src/trunk/ext/standard/strnatcmp.c 2009-08-07 17:32:31 UTC (rev 286916) @@ -105,7 +105,8 @@ { unsigned char ca, cb; unsigned int ai, bi; - int fractional, result, leading = true; + int fractional, result; + short leading = 1; ai = bi = 0; while (1) { @@ -120,7 +121,7 @@ cb = b[++bi]; } - leading = false; + leading = 0; /* process run of digits */ if (isdigit((int)(unsigned char)ca)isdigit((int)(unsigned char)cb)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php