diff --git a/include/wx/tokenzr.h b/include/wx/tokenzr.h index 764b4c8091..8012854ac6 100644 --- a/include/wx/tokenzr.h +++ b/include/wx/tokenzr.h @@ -47,6 +47,8 @@ public: protected: off_t FindDelims(const wxString& str, const wxString& delims); + void EatLeadingDelims(); // AVS - added to fix leading whitespace / + // mult. delims bugs protected: wxString m_string, m_delims; bool m_retdelims; diff --git a/src/common/tokenzr.cpp b/src/common/tokenzr.cpp index 34079c0f66..19ae5e0f29 100644 --- a/src/common/tokenzr.cpp +++ b/src/common/tokenzr.cpp @@ -82,6 +82,16 @@ bool wxStringTokenizer::HasMoreToken() return (m_string.Length() != 0); } +// AVS - added to fix leading whitespace / mult. delims bugs +void wxStringTokenizer::EatLeadingDelims() +{ + int pos; + + while ((pos=FindDelims(m_string, m_delims))==0) { // while leading delims + m_string = m_string.Mid((size_t)1); // trim 'em from the left + } +} + wxString wxStringTokenizer::NextToken() { register off_t pos, pos2; @@ -90,6 +100,10 @@ wxString wxStringTokenizer::NextToken() if (m_string.IsNull()) return m_string; + if (!m_retdelims) + EatLeadingDelims(); // AVS - added to fix leading whitespace / + // mult. delims bugs + pos = FindDelims(m_string, m_delims); if (pos == -1) { r_string = m_string;