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" ) );
|
const wxString header( wxS( "@package" ) );
|
||||||
|
|
||||||
// Extract substring between @package and endsection
|
// 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;
|
return wxEmptyString;
|
||||||
|
|
||||||
strstart += header.Length();
|
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;
|
return wxEmptyString;
|
||||||
|
|
||||||
// Remove empty line if any
|
// 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"`
|
// looks for output argument of the form `"%O.extension"`
|
||||||
const wxString outputarg( wxS( "\"%O" ) );
|
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;
|
return wxEmptyString;
|
||||||
|
|
||||||
strstart += outputarg.Length();
|
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 wxEmptyString;
|
||||||
|
|
||||||
return aHeader.SubString( strstart, strend - 1 );
|
return aHeader.SubString( strstart, strend - 1 );
|
||||||
|
|
|
@ -1097,9 +1097,9 @@ SCH_TEXT* SCH_IO_KICAD_LEGACY::loadText( LINE_READER& aReader )
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
int i = val.find( wxT( "\\n" ) );
|
size_t i = val.find( wxT( "\\n" ) );
|
||||||
|
|
||||||
if( i == wxNOT_FOUND )
|
if( i == wxString::npos )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
val.erase( i, 2 );
|
val.erase( i, 2 );
|
||||||
|
|
|
@ -78,8 +78,8 @@ namespace SEXPR
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<SEXPR> PARSER::parseString(
|
std::unique_ptr<SEXPR> PARSER::parseString( const std::string& aString,
|
||||||
const std::string& aString, std::string::const_iterator& it )
|
std::string::const_iterator& it )
|
||||||
{
|
{
|
||||||
for( ; it != aString.end(); ++it )
|
for( ; it != aString.end(); ++it )
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ namespace SEXPR
|
||||||
if( *it == '\n' )
|
if( *it == '\n' )
|
||||||
m_lineNumber++;
|
m_lineNumber++;
|
||||||
|
|
||||||
if( whitespaceCharacters.find(*it) != std::string::npos )
|
if( whitespaceCharacters.find( *it ) != std::string::npos )
|
||||||
{
|
{
|
||||||
std::advance( it, 1 );
|
std::advance( it, 1 );
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -632,7 +632,7 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||||
{
|
{
|
||||||
std::string del = ",";
|
std::string del = ",";
|
||||||
std::string paramStr = payload.substr( prefix.size() );
|
std::string paramStr = payload.substr( prefix.size() );
|
||||||
int modeEnd = paramStr.find( del );
|
size_t modeEnd = paramStr.find( del );
|
||||||
bool selectConnections = false;
|
bool selectConnections = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -651,13 +651,9 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||||
m_probingSchToPcb = true; // recursion guard
|
m_probingSchToPcb = true; // recursion guard
|
||||||
|
|
||||||
if( selectConnections )
|
if( selectConnections )
|
||||||
{
|
|
||||||
GetToolManager()->RunAction( PCB_ACTIONS::syncSelectionWithNets, &items );
|
GetToolManager()->RunAction( PCB_ACTIONS::syncSelectionWithNets, &items );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
GetToolManager()->RunAction( PCB_ACTIONS::syncSelection, &items );
|
GetToolManager()->RunAction( PCB_ACTIONS::syncSelection, &items );
|
||||||
}
|
|
||||||
|
|
||||||
// Update 3D viewer highlighting
|
// Update 3D viewer highlighting
|
||||||
Update3DView( false, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
|
Update3DView( false, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
|
||||||
|
|
|
@ -244,7 +244,7 @@ void DIALOG_BOARD_REANNOTATE::FilterPrefix( wxTextCtrl* aPrefix )
|
||||||
if( isalnum( (int) lastc ) )
|
if( isalnum( (int) lastc ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( std::string::npos != tmps.find( lastc ) )
|
if( tmps.find( lastc ) != std::string::npos )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tmps = aPrefix->GetValue();
|
tmps = aPrefix->GetValue();
|
||||||
|
@ -894,7 +894,7 @@ void DIALOG_BOARD_REANNOTATE::BuildChangeArray( std::vector<REFDES_INFO>& aFootp
|
||||||
|
|
||||||
if( change.Action == UPDATE_REFDES )
|
if( change.Action == UPDATE_REFDES )
|
||||||
{
|
{
|
||||||
prefixpresent = ( 0 == fpData.RefDesType.find( aPrefix ) );
|
prefixpresent = ( fpData.RefDesType.find( aPrefix ) == 0 );
|
||||||
|
|
||||||
if( addprefix && !prefixpresent )
|
if( addprefix && !prefixpresent )
|
||||||
fpData.RefDesType.insert( 0, aPrefix ); // Add prefix once only
|
fpData.RefDesType.insert( 0, aPrefix ); // Add prefix once only
|
||||||
|
|
|
@ -93,12 +93,12 @@ public:
|
||||||
wxString doc;
|
wxString doc;
|
||||||
|
|
||||||
// It is currently common practice to store a documentation link in the description.
|
// 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:" ) );
|
idx = desc.find( wxT( "https:" ) );
|
||||||
|
|
||||||
if( idx >= 0 )
|
if( idx != wxString::npos )
|
||||||
{
|
{
|
||||||
int nesting = 0;
|
int nesting = 0;
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
// Trim trailing punctuation
|
// Trim trailing punctuation
|
||||||
static wxString punct = wxS( ".,:;" );
|
static wxString punct = wxS( ".,:;" );
|
||||||
|
|
||||||
if( punct.find( doc.Last() ) >= 0 )
|
if( punct.find( doc.Last() ) != wxString::npos )
|
||||||
doc = doc.Left( doc.Length() - 1 );
|
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.
|
// The drill diameter is encoded in the padstack name if Pcbnew did the DSN export.
|
||||||
// It is after the colon and before the last '_'
|
// 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 ':'
|
++drillStartNdx; // skip over the ':'
|
||||||
|
|
||||||
int drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
|
size_t drillEndNdx = aPadstack->m_padstack_id.rfind( '_' );
|
||||||
if( drillEndNdx != -1 )
|
|
||||||
{
|
|
||||||
std::string diam_txt( aPadstack->m_padstack_id,
|
|
||||||
drillStartNdx, drillEndNdx-drillStartNdx );
|
|
||||||
|
|
||||||
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 ) );
|
drill_diam_iu = int( drill_um * ( pcbIUScale.IU_PER_MM / 1000.0 ) );
|
||||||
|
|
||||||
|
|
|
@ -903,7 +903,7 @@ bool WRLPROC::ReadSFInt( int& aSFInt32 )
|
||||||
return false;
|
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
|
// Rules: "0x" + "0-9, A-F" - VRML is case sensitive but in
|
||||||
// this instance we do no enforce case.
|
// this instance we do no enforce case.
|
||||||
|
|
Loading…
Reference in New Issue