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

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