- wxString p_string = m_string;
- bool found = TRUE;
- int pos, count = 1;
-
- if (p_string.Length() == 0)
- return 0;
-
- while (found)
- {
- pos = FindDelims(p_string, m_delims);
- if (pos != -1)
+ size_t pos = 0;
+ int count = 0;
+ bool at_delim;
+
+ while (pos < m_string.length()) {
+ // while we're still counting ...
+ at_delim = (m_delims.find(m_string.at(pos)) < m_delims.length());
+ // are we at a delimiter? if so, move to the next nondelimiter;
+ // if not, move to the next delimiter. If the find_first_of
+ // and find_first_not_of methods fail, pos will be assigned
+ // npos (0xFFFFFFFF) which will terminate the loop on the next
+ // go-round unless we have a really long string, which is unlikely
+ pos = at_delim ? m_string.find_first_not_of(m_delims, pos)
+ : m_string.find_first_of(m_delims, pos);
+ if (m_retdelims)