]> granicus.if.org Git - php/commitdiff
MFZE1
authorZeev Suraski <zeev@php.net>
Sun, 12 May 2002 15:59:29 +0000 (15:59 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 12 May 2002 15:59:29 +0000 (15:59 +0000)
Zend/zend_highlight.c

index f342e4dad6c555fb03560b1f5a4ee641fded0d1e..1a3c3403f962662c7f523880061144ab44c0752a 100644 (file)
@@ -58,16 +58,21 @@ ZEND_API void zend_html_puts(const char *s, uint len)
        const char *ptr=s, *end=s+len;
        
        while (ptr<end) {
-               if (*ptr==' '
-                       && len>1
-                       && !(((ptr+1)>=end) || (*(ptr+1)==' ')) /* next is not a space */
-                       && !((ptr==s) || (*(ptr-1)==' '))) /* last is not a space */ {
-                       char c = *ptr++;
-
-                       ZEND_PUTC(c);
-                       continue;
+               if (*ptr==' ') {
+                       /* Series of spaces should be displayed as &nbsp;'s
+                        * whereas single spaces should be displayed as a space
+                        */
+                       if ((ptr+1) < end && *(ptr+1)==' ') {
+                               do {
+                                       zend_html_putc(*ptr);
+                               } while ((++ptr < end) && (*ptr==' '));
+                       } else {
+                               ZEND_PUTC(*ptr);
+                               ptr++;
+                       }
+               } else {
+                       zend_html_putc(*ptr++);
                }
-               zend_html_putc(*ptr++);
        }
 }