aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-08-02 03:31:55 +0000
committercorvid <corvid@lavabit.com>2009-08-02 03:31:55 +0000
commit1ee0cb3aca76ca7661f5498ea0a73ff3e71ec569 (patch)
treec20986237cf6f8bf164e3502609704b5d61c2580
parentedfa11976a21dbb0aa000ac29038e37446db5756 (diff)
split words that contain whitespace
e.g. dillo&#32;browser
-rw-r--r--src/html.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/html.cc b/src/html.cc
index 79be4253..e5dde22f 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1122,7 +1122,7 @@ static void Html_process_space(DilloHtml *html, const char *space,
* Entities are parsed (or not) according to parse_mode.
* 'word' is a '\0'-terminated string.
*/
-static void Html_process_word(DilloHtml *html, const char *word, int size)
+static void Html_process_word(DilloHtml *html, char *word, int size)
{
int i, j, start;
char *Pword, ch;
@@ -1167,12 +1167,16 @@ static void Html_process_word(DilloHtml *html, const char *word, int size)
dFree(Pword);
} else {
+ char *Pword_end;
+
if (!memchr(word,'&', size)) {
/* No entities */
- HT2TB(html)->addText(word, html->styleEngine->wordStyle ());
+ Pword = word;
+ Pword_end = Pword + size - 1;
} else {
/* Collapse white-space entities inside the word (except &nbsp;) */
Pword = a_Html_parse_entities(html, word, size);
+ Pword_end = Pword + strlen(Pword) - 1;
/* Collapse adjacent " \t\f\n\r" characters into a single space */
for (i = j = 0; (Pword[i] = Pword[j]); ++i, ++j) {
if (strchr(" \t\f\n\r", Pword[i])) {
@@ -1183,12 +1187,24 @@ static void Html_process_word(DilloHtml *html, const char *word, int size)
;
}
}
- HT2TB(html)->addText(Pword, html->styleEngine->wordStyle ());
- dFree(Pword);
}
+ for (start = i = 0; Pword[i]; start = i) {
+ if (isspace(Pword[i])) {
+ while (Pword[++i] && isspace(Pword[i])) ;
+ Html_process_space(html, Pword + start, i - start);
+ } else {
+ while (Pword[++i] && !isspace(Pword[i])) ;
+ ch = Pword[i];
+ Pword[i] = '\0';
+ HT2TB(html)->addText(Pword + start,
+ html->styleEngine->wordStyle ());
+ Pword[i] = ch;
+ html->PrevWasSPC = false;
+ }
+ }
+ if (word != Pword)
+ dFree(Pword);
}
-
- html->PrevWasSPC = false;
if (html->InFlags & IN_LI)
html->WordAfterLI = true;
}