diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-01-26 13:31:09 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-01-26 13:31:09 -0300 |
commit | a842fe0d3c72fab66f67929739aa556caa6ee417 (patch) | |
tree | c74751d2d5bb72671783abddfd7e66a65c29890e /src | |
parent | 0ad791eae6bd8d6905eaa35186ac73f5f0d05b30 (diff) |
Bug fix: Collapse adjacent "\t\f\n\r" characters into a single space.
Test case: http://www.dillo.org/test/weird_pre.html
Diffstat (limited to 'src')
-rw-r--r-- | src/html.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/html.cc b/src/html.cc index c59a9ddd..356d08f8 100644 --- a/src/html.cc +++ b/src/html.cc @@ -1164,10 +1164,15 @@ static void Html_process_word(DilloHtml *html, const char *word, int size) } else { /* Collapse white-space entities inside the word (except ) */ Pword = a_Html_parse_entities(html, word, size); - for (i = 0; Pword[i]; ++i) - if (strchr("\t\f\n\r", Pword[i])) - for (j = i; (Pword[j] = Pword[j+1]); ++j) ; - + /* 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])) { + if (i == 0 || (i > 0 && Pword[i-1] != ' ')) + Pword[i] = ' '; + else + for (--i; strchr("\t\f\n\r", Pword[j+1]); ++j) ; + } + } DW2TB(html->dw)->addText(Pword, html->styleEngine->wordStyle ()); dFree(Pword); } |