From: Sascha Schumann Date: Sun, 12 May 2002 15:22:11 +0000 (+0000) Subject: Simplify white space handling in php_html_puts. X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c4ae1367008ad7fa5f679aba57467d4b4de317a;p=php Simplify white space handling in php_html_puts. If we encounter a ' ', we will look for the next non-' ' and set p accordingly. --- diff --git a/main/main.c b/main/main.c index 26c21068b8..9d96ad5ee0 100644 --- a/main/main.c +++ b/main/main.c @@ -401,15 +401,13 @@ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) smart_str_appendl(&s, "&", sizeof("&")-1); break; case ' ': { - const char *nextchar = p+1, *prevchar = p-1; + const char *nextchar = p; - /* series of spaces should be converted to  's */ - if (((nextchar < end) && *nextchar==' ') - || ((prevchar >= str) && *prevchar==' ')) { - smart_str_appendl(&s, " ", sizeof(" ")-1); - } else { - smart_str_appendc(&s, ' '); - } + while (++nextchar < end && *nextchar == ' '); + + p = nextchar; + smart_str_appends(&s, " "); + continue; } break; case '\t':