Fix new bus parsers to correctly handle non-buses.

Fixes https://gitlab.com/kicad/code/kicad/issues/4403
This commit is contained in:
Jeff Young 2020-05-11 22:54:59 +01:00
parent 74ee143d45
commit 105f85e551
2 changed files with 20 additions and 6 deletions

View File

@ -247,13 +247,14 @@ void NETLIST_OBJECT::ConvertBusToNetListItems( NETLIST_OBJECT_LIST& aNetListItem
bool self_set = false; bool self_set = false;
std::vector<wxString> bus_contents_vec; std::vector<wxString> bus_contents_vec;
if( alias || SCH_CONNECTION::ParseBusGroup( m_Label, &group_name, &bus_contents_vec ) )
{
if( alias ) if( alias )
{ {
for( const wxString& member : alias->Members() ) for( const wxString& member : alias->Members() )
bus_contents_vec.emplace_back( member ); bus_contents_vec.emplace_back( member );
} }
else if( SCH_CONNECTION::ParseBusGroup( m_Label, &group_name, &bus_contents_vec ) )
{
// For named bus groups, like "USB{DP DM}" // For named bus groups, like "USB{DP DM}"
wxString group_prefix = ( group_name != "" ) ? ( group_name + "." ) : ""; wxString group_prefix = ( group_name != "" ) ? ( group_name + "." ) : "";

View File

@ -429,6 +429,8 @@ bool SCH_CONNECTION::ParseBusVector( const wxString& aBus, wxString* aName,
long end = 0; long end = 0;
int braceNesting = 0; int braceNesting = 0;
prefix.reserve( busLen );
// Parse prefix // Parse prefix
// //
for( ; i < busLen; ++i ) for( ; i < busLen; ++i )
@ -458,6 +460,9 @@ bool SCH_CONNECTION::ParseBusVector( const wxString& aBus, wxString* aName,
// //
i++; // '[' character i++; // '[' character
if( i >= busLen )
return false;
for( ; i < busLen; ++i ) for( ; i < busLen; ++i )
{ {
if( aBus[i] == '.' && i + 1 < busLen && aBus[i+1] == '.' ) if( aBus[i] == '.' && i + 1 < busLen && aBus[i+1] == '.' )
@ -477,6 +482,9 @@ bool SCH_CONNECTION::ParseBusVector( const wxString& aBus, wxString* aName,
// //
tmp = wxEmptyString; tmp = wxEmptyString;
if( i >= busLen )
return false;
for( ; i < busLen; ++i ) for( ; i < busLen; ++i )
{ {
if( aBus[i] == ']' ) if( aBus[i] == ']' )
@ -543,6 +551,8 @@ bool SCH_CONNECTION::ParseBusGroup( wxString aGroup, wxString* aName,
wxString tmp; wxString tmp;
int braceNesting = 0; int braceNesting = 0;
prefix.reserve( groupLen );
// Parse prefix // Parse prefix
// //
for( ; i < groupLen; ++i ) for( ; i < groupLen; ++i )
@ -575,6 +585,9 @@ bool SCH_CONNECTION::ParseBusGroup( wxString aGroup, wxString* aName,
// //
i++; // '{' character i++; // '{' character
if( i >= groupLen )
return false;
for( ; i < groupLen; ++i ) for( ; i < groupLen; ++i )
{ {
if( aGroup[i] == '{' ) if( aGroup[i] == '{' )