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 ) bool SCH_CONNECTION::IsBusVectorLabel( const wxString& aLabel )
{ {
try
{
return std::regex_match( std::string( aLabel.mb_str() ), bus_label_re ); return std::regex_match( std::string( aLabel.mb_str() ), bus_label_re );
}
catch( ... )
{
return false;
}
} }
bool SCH_CONNECTION::IsBusGroupLabel( const wxString& aLabel ) bool SCH_CONNECTION::IsBusGroupLabel( const wxString& aLabel )
{ {
try
{
return std::regex_match( std::string( aLabel.mb_str() ), bus_group_label_re ); return std::regex_match( std::string( aLabel.mb_str() ), bus_group_label_re );
}
catch( ... )
{
return false;
}
} }
@ -385,11 +399,18 @@ void SCH_CONNECTION::ParseBusVector( wxString aVector, wxString* aName,
auto ss_vector = std::string( aVector.mb_str() ); auto ss_vector = std::string( aVector.mb_str() );
std::smatch matches; std::smatch matches;
try
{
if( !std::regex_match( ss_vector, matches, bus_label_re ) ) if( !std::regex_match( ss_vector, matches, bus_label_re ) )
{ {
wxFAIL_MSG( wxT( "<" ) + aVector + wxT( "> is not a valid bus vector." ) ); wxFAIL_MSG( wxT( "<" ) + aVector + wxT( "> is not a valid bus vector." ) );
return; return;
} }
}
catch( ... )
{
return;
}
*aName = wxString( matches[1] ); *aName = wxString( matches[1] );
wxString numberString( matches[2] ); wxString numberString( matches[2] );
@ -436,10 +457,17 @@ bool SCH_CONNECTION::ParseBusGroup( wxString aGroup, wxString* aName,
auto ss_group = std::string( aGroup.mb_str() ); auto ss_group = std::string( aGroup.mb_str() );
std::smatch matches; std::smatch matches;
try
{
if( !std::regex_match( ss_group, matches, bus_group_label_re ) ) if( !std::regex_match( ss_group, matches, bus_group_label_re ) )
{ {
return false; return false;
} }
}
catch( ... )
{
return false;
}
*aName = wxString( matches[1] ); *aName = wxString( matches[1] );