From 0d00401fba68819b19a0ab6f801e119b80f445d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 5 May 2008 10:53:58 +0000 Subject: [PATCH] fixed   handling in wxHtmlWinParser, broken by TAB-handling changes (bug #1957041) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53457 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/html/winpars.h | 2 +- src/html/winpars.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h index a6ebf18283..b7da33c93a 100644 --- a/include/wx/html/winpars.h +++ b/include/wx/html/winpars.h @@ -161,7 +161,7 @@ protected: virtual void AddText(const wxChar* txt); private: - void FlushWordBuf(wxChar *temp, int& templen); + void FlushWordBuf(wxChar *temp, int& templen, wxChar nbsp); void AddWord(wxHtmlWordCell *c); void AddWord(const wxString& word); void AddPreBlock(const wxString& text); diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 331709a4b6..785e76cf4b 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -496,7 +496,7 @@ void wxHtmlWinParser::AddText(const wxChar* txt) while (i < lng) { x = 0; - wxChar d = txt[i]; + const wxChar d = temp[templen++] = txt[i]; if ((d == wxT('\n')) || (d == wxT('\r')) || (d == wxT(' ')) || (d == wxT('\t'))) { i++, x++; @@ -505,22 +505,17 @@ void wxHtmlWinParser::AddText(const wxChar* txt) } else i++; - if ( d == nbsp ) - d = wxT(' '); - - temp[templen++] = d; - if (x) { temp[templen-1] = wxT(' '); - FlushWordBuf(temp, templen); + FlushWordBuf(temp, templen, nbsp); m_tmpLastWasSpace = true; } } if (templen && (templen > 1 || temp[0] != wxT(' '))) { - FlushWordBuf(temp, templen); + FlushWordBuf(temp, templen, nbsp); m_tmpLastWasSpace = false; } } @@ -547,10 +542,16 @@ void wxHtmlWinParser::AddText(const wxChar* txt) } } -void wxHtmlWinParser::FlushWordBuf(wxChar *buf, int& len) +void wxHtmlWinParser::FlushWordBuf(wxChar *buf, int& len, wxChar nbsp) { buf[len] = 0; + for ( int i = 0; i < len; i++ ) + { + if ( buf[i] == nbsp ) + buf[i] = ' '; + } + #if !wxUSE_UNICODE if (m_EncConv) m_EncConv->Convert(buf);