cvs: php4 /main main.c

From: Date: Sat, 11 May 2002 12:17:57 +0000
Subject: cvs: php4 /main main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11828@lists.php.net to get a copy of this message
zeev Sat May 11 08:17:57 2002 EDT Modified files: /php4/main main.c Log: Removing HTMLization of ' ' wasn't ok, it didn't deal with series of spaces properly. Turn series of spaces into &nbsp;'s. Index: php4/main/main.c diff -u php4/main/main.c:1.450 php4/main/main.c:1.451 --- php4/main/main.c:1.450 Fri May 10 23:41:16 2002 +++ php4/main/main.c Sat May 11 08:17:53 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.450 2002/05/11 03:41:16 zeev Exp $ */ +/* $Id: main.c,v 1.451 2002/05/11 12:17:53 zeev Exp $ */ /* {{{ includes */ @@ -382,11 +382,12 @@ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) { - const char *estr; + const char *end = str+size; + const char *p = str; smart_str s = {0}; - for (estr = str + size; str < estr; str++) { - switch (*str) { + while (p < end) { + switch (*p) { case '\n': smart_str_appendl(&s, "<br />", sizeof("<br />")-1); break; @@ -399,19 +400,25 @@ case '&': smart_str_appendl(&s, "&amp;", sizeof("&amp;")-1); break; + case ' ': { + const char *nextchar = p+1, *prevchar = p-1; -/* Commented out since this is not necessary */ -/* - case ' ': - smart_str_appendl(&s, "&nbsp;", sizeof("&nbsp;")-1); + /* 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, ' '); + } + } break; -*/ case '\t': smart_str_appendl(&s, "&nbsp;&nbsp;&nbsp;&nbsp;", sizeof("&nbsp;&nbsp;&nbsp;&nbsp;")-1); break; default: - smart_str_appendc(&s, *str); + smart_str_appendc(&s, *p); } + p++; } if (s.c) {

« previous php.cvs (#11828) next »