]> granicus.if.org Git - php/commitdiff
Simplify white space handling in php_html_puts.
authorSascha Schumann <sas@php.net>
Sun, 12 May 2002 15:22:11 +0000 (15:22 +0000)
committerSascha Schumann <sas@php.net>
Sun, 12 May 2002 15:22:11 +0000 (15:22 +0000)
If we encounter a ' ', we will look for the next non-' ' and set p
accordingly.

main/main.c

index 26c21068b82617de379a365f9a9561c453a17da0..9d96ad5ee0677ac52168b94fe2d07da4479b4068 100644 (file)
@@ -401,15 +401,13 @@ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
                                smart_str_appendl(&s, "&amp;", sizeof("&amp;")-1);
                                break;
                        case ' ': {
-                                       const char *nextchar = p+1, *prevchar = p-1;
+                                       const char *nextchar = p;
 
-                                       /* series of spaces should be converted to &nbsp;'s */
-                                       if (((nextchar < end) && *nextchar==' ')
-                                               || ((prevchar >= str) && *prevchar==' ')) {
-                                               smart_str_appendl(&s, "&nbsp;", sizeof("&nbsp;")-1);
-                                       } else {
-                                               smart_str_appendc(&s, ' ');
-                                       }
+                                       while (++nextchar < end && *nextchar == ' ');
+
+                                       p = nextchar;
+                                       smart_str_appends(&s, "&nbsp;");
+                                       continue;
                                }
                                break;
                        case '\t':