rasmus Sat, 08 Aug 2009 14:39:34 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=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) && 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