]> granicus.if.org Git - php/commitdiff
Restore intra-string whitespace collapsing broken in the previous change.
authorRasmus Lerdorf <rasmus@php.net>
Sat, 8 Aug 2009 14:39:34 +0000 (14:39 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Sat, 8 Aug 2009 14:39:34 +0000 (14:39 +0000)
ext/standard/strnatcmp.c

index 2d7ecd817868cce17517f23c32a10d37f7e6ed75..a071fd186f03394a38c7fb8c5cc0b18f8dac5c14 100644 (file)
@@ -116,17 +116,26 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len
        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');