diff --git a/common/eda_doc.cpp b/common/eda_doc.cpp index 4317176935..6d3ea02087 100644 --- a/common/eda_doc.cpp +++ b/common/eda_doc.cpp @@ -211,34 +211,27 @@ bool GetAssociatedDocument( wxWindow* aParent, } -int KeyWordOk( const wxString& KeyList, const wxString& Database ) +bool KeywordMatch( const wxString& aKeys, const wxString& aDatabase ) { - wxString KeysCopy, DataList; + if( aKeys.IsEmpty() ) + return false; - if( KeyList.IsEmpty() ) - return 0; + wxStringTokenizer keyTokenizer( aKeys, wxT( ", \t\n\r" ), wxTOKEN_STRTOK ); - KeysCopy = KeyList; KeysCopy.MakeUpper(); - DataList = Database; DataList.MakeUpper(); - - wxStringTokenizer Token( KeysCopy, wxT( " \n\r" ) ); - - while( Token.HasMoreTokens() ) + while( keyTokenizer.HasMoreTokens() ) { - wxString Key = Token.GetNextToken(); + wxString key = keyTokenizer.GetNextToken(); - // Search Key in Datalist: - wxStringTokenizer Data( DataList, wxT( " \n\r" ) ); + // Search for key in aDatabase: + wxStringTokenizer dataTokenizer( aDatabase, wxT( ", \t\n\r" ), wxTOKEN_STRTOK ); - while( Data.HasMoreTokens() ) + while( dataTokenizer.HasMoreTokens() ) { - wxString word = Data.GetNextToken(); - - if( word == Key ) - return 1; // Key found ! + if( dataTokenizer.GetNextToken() == key ) + return true; } } // keyword not found - return 0; + return false; } diff --git a/include/eda_doc.h b/include/eda_doc.h index b9df60de4f..194783e0f8 100644 --- a/include/eda_doc.h +++ b/include/eda_doc.h @@ -33,12 +33,12 @@ /** - * Function KeyWordOk + * Function KeywordMatch * searches \a aKeyList for any words found in \a aDatabase. * - * @return 0 if no keyword is found or 1 if keyword is found. + * @return true if keyword is found. */ -int KeyWordOk( const wxString& aKeyList, const wxString& aDatabase ); +bool KeywordMatch( const wxString& aKeys, const wxString& aDatabase ); /** * Function GetAssociatedDocument diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index 42b7b1aa85..0316011664 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -430,9 +430,11 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, if( !aKeyWord.IsEmpty() ) // Create a list of modules found by keyword. { + wxString keyword = aKeyWord.Upper(); + for( unsigned ii = 0; ii < MList.GetCount(); ii++ ) { - if( KeyWordOk( aKeyWord, MList.GetItem( ii ).GetKeywords() ) ) + if( KeywordMatch( keyword, MList.GetItem( ii ).GetKeywords().Upper() ) ) { wxArrayString cols; cols.Add( MList.GetItem( ii ).GetFootprintName() );