X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/906c935a80b10d53cecf57f71ab5f3f4f1d529ec..8f9acf6cc9f6c559d4174655814153c16286a08e:/src/html/m_tables.cpp diff --git a/src/html/m_tables.cpp b/src/html/m_tables.cpp index 7bca5a4c3f..1b96963be3 100644 --- a/src/html/m_tables.cpp +++ b/src/html/m_tables.cpp @@ -288,7 +288,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) { wxString wd = tag.GetParam(wxT("WIDTH")); - if (wd[wd.length()-1] == wxT('%')) + if (!wd.empty() && wd[wd.length()-1] == wxT('%')) { if ( wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width) == 1 ) { @@ -702,19 +702,18 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") { if (tag.HasParam(wxT("WIDTH"))) { - wxString wd = tag.GetParam(wxT("WIDTH")); - - if (wd[wd.length()-1] == wxT('%')) - { - int width = 0; - wxSscanf(wd.c_str(), wxT("%i%%"), &width); - m_Table->SetWidthFloat(width, wxHTML_UNITS_PERCENT); - } - else + int width = 0; + bool wpercent = false; + if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &width, wpercent)) { - int width = 0; - wxSscanf(wd.c_str(), wxT("%i"), &width); - m_Table->SetWidthFloat((int)(m_WParser->GetPixelScale() * width), wxHTML_UNITS_PIXELS); + if (wpercent) + { + m_Table->SetWidthFloat(width, wxHTML_UNITS_PERCENT); + } + else + { + m_Table->SetWidthFloat((int)(m_WParser->GetPixelScale() * width), wxHTML_UNITS_PIXELS); + } } } else