From f187f91f5797f93c970c4ad922aab57f4918ee9c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 2 May 2019 00:48:29 +0100 Subject: [PATCH] Seth's fixes to regex processing. --- eeschema/sch_connection.cpp | 40 +++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 45faa93937..a02194f172 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -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; -} +} \ No newline at end of file