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,25 +2607,21 @@ 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 )
|
||||
auto ret = MapPadNumbersToNetTieGroups();
|
||||
|
||||
for( auto [ padNumber, _ ] : ret )
|
||||
{
|
||||
wxStringTokenizer groupParser( m_netTiePadGroups[ ii ], "," );
|
||||
const PAD* pad = FindPadByNumber( padNumber );
|
||||
|
||||
while( groupParser.HasMoreTokens() )
|
||||
if( !pad )
|
||||
{
|
||||
wxString padNumber( groupParser.GetNextToken().Trim( false ).Trim( true ) );
|
||||
const PAD* pad = FindPadByNumber( padNumber );
|
||||
|
||||
if( !pad )
|
||||
{
|
||||
msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
|
||||
aErrorHandler( msg );
|
||||
}
|
||||
else if( !padNumbers.insert( pad->GetNumber() ).second )
|
||||
{
|
||||
msg.Printf( _( "(pad %s appears in more than one net-tie pad group)" ), padNumber );
|
||||
aErrorHandler( msg );
|
||||
}
|
||||
msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
|
||||
aErrorHandler( msg );
|
||||
}
|
||||
else if( !padNumbers.insert( pad->GetNumber() ).second )
|
||||
{
|
||||
msg.Printf( _( "(pad %s appears in more than one net-tie pad group)" ), padNumber );
|
||||
aErrorHandler( msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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