wxStringTokenizer usage cleanup.
1) Always be explicit about what the delimiters are 2) If space is a delimiter, we probably want to skip empty fields (wxTOKEN_STRTOK) 3) If space is not a delimiter, we often need to trim the resultant tokens 4) Be more lenient about \t\r\n (and when they are included, include them in the same order)
This commit is contained in:
@@ -394,19 +394,21 @@ void ReadHotKeyConfig( const wxString& aFileName,
|
||||
wxString input;
|
||||
file.ReadAll( &input );
|
||||
input.Replace( "\r\n", "\n" ); // Convert Windows files to Unix line-ends
|
||||
wxStringTokenizer fileTokenizer( input, wxS( "\n" ), wxTOKEN_STRTOK );
|
||||
wxStringTokenizer fileTokenizer( input, "\n", wxTOKEN_STRTOK );
|
||||
|
||||
while( fileTokenizer.HasMoreTokens() )
|
||||
{
|
||||
wxStringTokenizer lineTokenizer( fileTokenizer.GetNextToken(), wxS( "\t" ) );
|
||||
wxStringTokenizer lineTokenizer( fileTokenizer.GetNextToken(), "\t" );
|
||||
|
||||
wxString cmdName = lineTokenizer.GetNextToken();
|
||||
wxString primary = lineTokenizer.GetNextToken();
|
||||
wxString secondary = lineTokenizer.GetNextToken();
|
||||
|
||||
if( !cmdName.IsEmpty() )
|
||||
aHotKeys[cmdName.ToStdString()] = std::pair<int, int>(
|
||||
KeyCodeFromKeyName( primary ), KeyCodeFromKeyName( secondary ) );
|
||||
{
|
||||
aHotKeys[cmdName.ToStdString()] = std::pair<int, int>( KeyCodeFromKeyName( primary ),
|
||||
KeyCodeFromKeyName( secondary ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,12 +509,12 @@ int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string,
|
||||
data.Replace( "\\n", "\n", true );
|
||||
|
||||
// parse
|
||||
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
|
||||
wxStringTokenizer tokenizer( data, "\r\n", wxTOKEN_STRTOK );
|
||||
|
||||
while( tokenizer.HasMoreTokens() )
|
||||
{
|
||||
wxString line = tokenizer.GetNextToken();
|
||||
wxStringTokenizer lineTokenizer( line );
|
||||
wxStringTokenizer lineTokenizer( line, " \t\r\n" );
|
||||
|
||||
wxString line_type = lineTokenizer.GetNextToken();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user