From cb734537f4e90184cd2bca536779c22bde795b98 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sat, 8 Aug 2009 14:39:34 +0000 Subject: [PATCH] Restore intra-string whitespace collapsing broken in the previous change. --- ext/standard/strnatcmp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c index bfea61f74f..b756a86afb 100644 --- a/ext/standard/strnatcmp.c +++ b/ext/standard/strnatcmp.c @@ -112,17 +112,26 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len 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'); -- 2.50.1