diff --git a/eeschema/bom_plugins.cpp b/eeschema/bom_plugins.cpp index 53641f42a2..766419ae8f 100644 --- a/eeschema/bom_plugins.cpp +++ b/eeschema/bom_plugins.cpp @@ -154,15 +154,15 @@ wxString BOM_GENERATOR_HANDLER::readHeader( const wxString& aEndSection ) const wxString header( wxS( "@package" ) ); // Extract substring between @package and endsection - int strstart = data.Find( header ); + size_t strstart = data.find( header ); - if( strstart == wxNOT_FOUND ) + if( strstart == wxString::npos ) return wxEmptyString; strstart += header.Length(); - int strend = data.find( aEndSection, strstart ); + size_t strend = data.find( aEndSection, strstart ); - if( strend == wxNOT_FOUND ) + if( strend == wxString::npos ) return wxEmptyString; // Remove empty line if any @@ -179,15 +179,15 @@ wxString BOM_GENERATOR_HANDLER::getOutputExtension( const wxString& aHeader ) // looks for output argument of the form `"%O.extension"` const wxString outputarg( wxS( "\"%O" ) ); - int strstart = aHeader.Find( outputarg ); + size_t strstart = aHeader.find( outputarg ); - if( strstart == wxNOT_FOUND ) + if( strstart == wxString::npos ) return wxEmptyString; strstart += outputarg.Length(); - int strend = aHeader.find( wxS( "\"" ), strstart ); + size_t strend = aHeader.find( wxS( "\"" ), strstart ); - if( strend == wxNOT_FOUND ) + if( strend == wxString::npos ) return wxEmptyString; return aHeader.SubString( strstart, strend - 1 ); diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp index 56e16761fb..6bc1166c19 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp @@ -1097,9 +1097,9 @@ SCH_TEXT* SCH_IO_KICAD_LEGACY::loadText( LINE_READER& aReader ) for( ; ; ) { - int i = val.find( wxT( "\\n" ) ); + size_t i = val.find( wxT( "\\n" ) ); - if( i == wxNOT_FOUND ) + if( i == wxString::npos ) break; val.erase( i, 2 ); diff --git a/libs/sexpr/sexpr_parser.cpp b/libs/sexpr/sexpr_parser.cpp index a15b2ce5c9..a245b0bec9 100644 --- a/libs/sexpr/sexpr_parser.cpp +++ b/libs/sexpr/sexpr_parser.cpp @@ -78,8 +78,8 @@ namespace SEXPR return str; } - std::unique_ptr PARSER::parseString( - const std::string& aString, std::string::const_iterator& it ) + std::unique_ptr PARSER::parseString( const std::string& aString, + std::string::const_iterator& it ) { for( ; it != aString.end(); ++it ) { @@ -101,7 +101,7 @@ namespace SEXPR if( *it == '\n' ) m_lineNumber++; - if( whitespaceCharacters.find(*it) != std::string::npos ) + if( whitespaceCharacters.find( *it ) != std::string::npos ) { std::advance( it, 1 ); continue; diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 1d572faf12..33b3c3229f 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -632,7 +632,7 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) { std::string del = ","; std::string paramStr = payload.substr( prefix.size() ); - int modeEnd = paramStr.find( del ); + size_t modeEnd = paramStr.find( del ); bool selectConnections = false; try @@ -651,13 +651,9 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) m_probingSchToPcb = true; // recursion guard if( selectConnections ) - { GetToolManager()->RunAction( PCB_ACTIONS::syncSelectionWithNets, &items ); - } else - { GetToolManager()->RunAction( PCB_ACTIONS::syncSelection, &items ); - } // Update 3D viewer highlighting Update3DView( false, GetPcbNewSettings()->m_Display.m_Live3DRefresh ); diff --git a/pcbnew/dialogs/dialog_board_reannotate.cpp b/pcbnew/dialogs/dialog_board_reannotate.cpp index 99635d6682..1fb62bf124 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.cpp +++ b/pcbnew/dialogs/dialog_board_reannotate.cpp @@ -244,7 +244,7 @@ void DIALOG_BOARD_REANNOTATE::FilterPrefix( wxTextCtrl* aPrefix ) if( isalnum( (int) lastc ) ) return; - if( std::string::npos != tmps.find( lastc ) ) + if( tmps.find( lastc ) != std::string::npos ) return; tmps = aPrefix->GetValue(); @@ -894,7 +894,7 @@ void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector& aFootp if( change.Action == UPDATE_REFDES ) { - prefixpresent = ( 0 == fpData.RefDesType.find( aPrefix ) ); + prefixpresent = ( fpData.RefDesType.find( aPrefix ) == 0 ); if( addprefix && !prefixpresent ) fpData.RefDesType.insert( 0, aPrefix ); // Add prefix once only diff --git a/pcbnew/generate_footprint_info.cpp b/pcbnew/generate_footprint_info.cpp index cdecfe5610..af75068cc4 100644 --- a/pcbnew/generate_footprint_info.cpp +++ b/pcbnew/generate_footprint_info.cpp @@ -93,12 +93,12 @@ public: wxString doc; // It is currently common practice to store a documentation link in the description. - int idx = desc.find( wxT( "http:" ) ); + size_t idx = desc.find( wxT( "http:" ) ); - if( idx < 0 ) + if( idx == wxString::npos ) idx = desc.find( wxT( "https:" ) ); - if( idx >= 0 ) + if( idx != wxString::npos ) { int nesting = 0; @@ -122,7 +122,7 @@ public: // Trim trailing punctuation static wxString punct = wxS( ".,:;" ); - if( punct.find( doc.Last() ) >= 0 ) + if( punct.find( doc.Last() ) != wxString::npos ) doc = doc.Left( doc.Length() - 1 ); } diff --git a/pcbnew/specctra_import_export/specctra_import.cpp b/pcbnew/specctra_import_export/specctra_import.cpp index de9246feac..cc10b251dc 100644 --- a/pcbnew/specctra_import_export/specctra_import.cpp +++ b/pcbnew/specctra_import_export/specctra_import.cpp @@ -184,19 +184,20 @@ PCB_VIA* SPECCTRA_DB::makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT& // The drill diameter is encoded in the padstack name if Pcbnew did the DSN export. // It is after the colon and before the last '_' - int drillStartNdx = aPadstack->m_padstack_id.find( ':' ); + size_t drillStartNdx = aPadstack->m_padstack_id.find( ':' ); - if( drillStartNdx != -1 ) + if( drillStartNdx != std::string::npos ) { ++drillStartNdx; // skip over the ':' - int drillEndNdx = aPadstack->m_padstack_id.rfind( '_' ); - if( drillEndNdx != -1 ) - { - std::string diam_txt( aPadstack->m_padstack_id, - drillStartNdx, drillEndNdx-drillStartNdx ); + size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' ); - double drill_um = strtod( diam_txt.c_str(), 0 ); + if( drillEndNdx != std::string::npos ) + { + std::string diam_txt( aPadstack->m_padstack_id, drillStartNdx, + drillEndNdx-drillStartNdx ); + + double drill_um = strtod( diam_txt.c_str(), nullptr ); drill_diam_iu = int( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) ); diff --git a/plugins/3d/vrml/wrlproc.cpp b/plugins/3d/vrml/wrlproc.cpp index 9b06b61490..8b7714b474 100644 --- a/plugins/3d/vrml/wrlproc.cpp +++ b/plugins/3d/vrml/wrlproc.cpp @@ -903,7 +903,7 @@ bool WRLPROC::ReadSFInt( int& aSFInt32 ) return false; } - if( std::string::npos != tmp.find( "0x" ) ) + if( tmp.find( "0x" ) != std::string::npos ) { // Rules: "0x" + "0-9, A-F" - VRML is case sensitive but in // this instance we do no enforce case.