Tidy up string find API usages.
This commit is contained in:
parent
11b72c294b
commit
bab97f91cc
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -78,8 +78,8 @@ namespace SEXPR
|
|||
return str;
|
||||
}
|
||||
|
||||
std::unique_ptr<SEXPR> PARSER::parseString(
|
||||
const std::string& aString, std::string::const_iterator& it )
|
||||
std::unique_ptr<SEXPR> 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;
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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<REFDES_INFO>& 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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ) );
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue