Seth's fixes to regex processing.

This commit is contained in:
Jeff Young 2019-05-02 00:48:29 +01:00
parent 1cc3055481
commit f187f91f57
1 changed files with 34 additions and 6 deletions

View File

@ -369,13 +369,27 @@ bool SCH_CONNECTION::IsBusLabel( const wxString& aLabel )
bool SCH_CONNECTION::IsBusVectorLabel( const wxString& aLabel )
{
return std::regex_match( std::string( aLabel.mb_str() ), bus_label_re );
try
{
return std::regex_match( std::string( aLabel.mb_str() ), bus_label_re );
}
catch( ... )
{
return false;
}
}
bool SCH_CONNECTION::IsBusGroupLabel( const wxString& aLabel )
{
return std::regex_match( std::string( aLabel.mb_str() ), bus_group_label_re );
try
{
return std::regex_match( std::string( aLabel.mb_str() ), bus_group_label_re );
}
catch( ... )
{
return false;
}
}
@ -385,9 +399,16 @@ void SCH_CONNECTION::ParseBusVector( wxString aVector, wxString* aName,
auto ss_vector = std::string( aVector.mb_str() );
std::smatch matches;
if( !std::regex_match( ss_vector, matches, bus_label_re ) )
try
{
if( !std::regex_match( ss_vector, matches, bus_label_re ) )
{
wxFAIL_MSG( wxT( "<" ) + aVector + wxT( "> is not a valid bus vector." ) );
return;
}
}
catch( ... )
{
wxFAIL_MSG( wxT( "<" ) + aVector + wxT( "> is not a valid bus vector." ) );
return;
}
@ -436,7 +457,14 @@ bool SCH_CONNECTION::ParseBusGroup( wxString aGroup, wxString* aName,
auto ss_group = std::string( aGroup.mb_str() );
std::smatch matches;
if( !std::regex_match( ss_group, matches, bus_group_label_re ) )
try
{
if( !std::regex_match( ss_group, matches, bus_group_label_re ) )
{
return false;
}
}
catch( ... )
{
return false;
}
@ -491,4 +519,4 @@ bool SCH_CONNECTION::IsMemberOfBus( SCH_CONNECTION* aOther ) const
return true;
return false;
}
}