Loading of recent character list simplified by using wxStringTokenizer
This commit is contained in:
parent
ace7551281
commit
92374e57a8
@ -42,9 +42,10 @@
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/persist.h>
|
||||
#include <wx/persist/toplevel.h>
|
||||
#include <wx/socket.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/utils.h>
|
||||
#include <wx/valtext.h>
|
||||
#include <wx/socket.h>
|
||||
|
||||
#include <WinStd/MSI.h>
|
||||
|
||||
|
@ -840,26 +840,11 @@ bool wxPersistentZRColaCharSelect::Restore()
|
||||
if (RestoreValue(wxT("recentChars2"), &str)) {
|
||||
// Native format found.
|
||||
wxArrayString val;
|
||||
for (wxStringTokenizer tok(str, wxT("|")); tok.HasMoreTokens(); ) {
|
||||
wxString chr;
|
||||
wchar_t c = 0;
|
||||
for (size_t i = 0, n = str.Length();; i++) {
|
||||
if (i >= n) {
|
||||
if (c) { chr += c; c = 0; }
|
||||
if (!chr.IsEmpty()) { val.Add(chr); chr.Clear(); }
|
||||
break;
|
||||
} else {
|
||||
wxStringCharType r = str[i];
|
||||
if (wxT('0') <= r && r <= wxT('9')) c = (c << 4) | (r - wxT('0') );
|
||||
else if (wxT('A') <= r && r <= wxT('F')) c = (c << 4) | (r - wxT('A') + 10);
|
||||
else if (wxT('a') <= r && r <= wxT('f')) c = (c << 4) | (r - wxT('a') + 10);
|
||||
else if (r == wxT('+')) {
|
||||
if (c) { chr += c; c = 0; }
|
||||
} else if (r == wxT('|')) {
|
||||
if (c) { chr += c; c = 0; }
|
||||
if (!chr.IsEmpty()) { val.Add(chr); chr.Clear(); }
|
||||
} else
|
||||
break;
|
||||
}
|
||||
for (wxStringTokenizer tok_chr(tok.GetNextToken(), wxT("+")); tok_chr.HasMoreTokens(); )
|
||||
chr += (wchar_t)_tcstoul(tok_chr.GetNextToken().c_str(), NULL, 16);
|
||||
val.Add(chr);
|
||||
}
|
||||
wnd->m_gridRecent->SetCharacters(val);
|
||||
} else if (RestoreValue(wxT("recentChars"), &str)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user