Allow commas, spaces in pad names for net-ties
Net tie groups are currently separated by comma. But comma is also an allowed, albeit rare character for pad names. To allow pad names with commas in net tie groups, the group definition must be escaped with a forward slash for commas (and forward slashes). Pad 1,2 Pad 2,3 Net-tie group "1\,2,2\,3" Fixes https://gitlab.com/kicad/code/kicad/issues/13001
This commit is contained in:
parent
171cffec28
commit
b99bd7633d
|
@ -2288,11 +2288,36 @@ std::map<wxString, int> FOOTPRINT::MapPadNumbersToNetTieGroups() const
|
|||
|
||||
for( size_t ii = 0; ii < m_netTiePadGroups.size(); ++ii )
|
||||
{
|
||||
wxStringTokenizer groupParser( m_netTiePadGroups[ ii ], "," );
|
||||
std::vector<wxString> numbersInGroup;
|
||||
wxString group( m_netTiePadGroups[ ii ] );
|
||||
bool esc = false;
|
||||
wxString pad;
|
||||
|
||||
while( groupParser.HasMoreTokens() )
|
||||
padNumberToGroupIdxMap[ groupParser.GetNextToken().Trim( false ).Trim( true ) ] = ii;
|
||||
for( auto ch : group )
|
||||
{
|
||||
if( esc )
|
||||
{
|
||||
esc = false;
|
||||
pad.Append( ch );
|
||||
continue;
|
||||
}
|
||||
|
||||
switch( static_cast<unsigned char>( ch ) )
|
||||
{
|
||||
case '\\':
|
||||
esc = true;
|
||||
break;
|
||||
|
||||
case ',':
|
||||
padNumberToGroupIdxMap[ pad ] = ii;
|
||||
pad.Clear();
|
||||
break;
|
||||
|
||||
default:
|
||||
pad.Append( ch );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return padNumberToGroupIdxMap;
|
||||
|
@ -2582,13 +2607,10 @@ void FOOTPRINT::CheckNetTiePadGroups( const std::function<void( const wxString&
|
|||
std::set<wxString> padNumbers;
|
||||
wxString msg;
|
||||
|
||||
for( size_t ii = 0; ii < m_netTiePadGroups.size(); ++ii )
|
||||
{
|
||||
wxStringTokenizer groupParser( m_netTiePadGroups[ ii ], "," );
|
||||
auto ret = MapPadNumbersToNetTieGroups();
|
||||
|
||||
while( groupParser.HasMoreTokens() )
|
||||
for( auto [ padNumber, _ ] : ret )
|
||||
{
|
||||
wxString padNumber( groupParser.GetNextToken().Trim( false ).Trim( true ) );
|
||||
const PAD* pad = FindPadByNumber( padNumber );
|
||||
|
||||
if( !pad )
|
||||
|
@ -2603,7 +2625,6 @@ void FOOTPRINT::CheckNetTiePadGroups( const std::function<void( const wxString&
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT::swapData( BOARD_ITEM* aImage )
|
||||
|
|
|
@ -282,7 +282,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @return a map from pad numbers to net-tie group indicies. If a pad is not a member of
|
||||
* @return a map from pad numbers to net-tie group indices. If a pad is not a member of
|
||||
* a net-tie group its index will be -1.
|
||||
*/
|
||||
std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
|
||||
|
|
Loading…
Reference in New Issue