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 )
|
for( size_t ii = 0; ii < m_netTiePadGroups.size(); ++ii )
|
||||||
{
|
{
|
||||||
wxStringTokenizer groupParser( m_netTiePadGroups[ ii ], "," );
|
wxString group( m_netTiePadGroups[ ii ] );
|
||||||
std::vector<wxString> numbersInGroup;
|
bool esc = false;
|
||||||
|
wxString pad;
|
||||||
|
|
||||||
while( groupParser.HasMoreTokens() )
|
for( auto ch : group )
|
||||||
padNumberToGroupIdxMap[ groupParser.GetNextToken().Trim( false ).Trim( true ) ] = ii;
|
{
|
||||||
|
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;
|
return padNumberToGroupIdxMap;
|
||||||
|
@ -2582,25 +2607,21 @@ void FOOTPRINT::CheckNetTiePadGroups( const std::function<void( const wxString&
|
||||||
std::set<wxString> padNumbers;
|
std::set<wxString> padNumbers;
|
||||||
wxString msg;
|
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 ) );
|
msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
|
||||||
const PAD* pad = FindPadByNumber( padNumber );
|
aErrorHandler( msg );
|
||||||
|
}
|
||||||
if( !pad )
|
else if( !padNumbers.insert( pad->GetNumber() ).second )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "(net-tie pad group contains unknown pad number %s)" ), padNumber );
|
msg.Printf( _( "(pad %s appears in more than one net-tie pad group)" ), padNumber );
|
||||||
aErrorHandler( msg );
|
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.
|
* a net-tie group its index will be -1.
|
||||||
*/
|
*/
|
||||||
std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
|
std::map<wxString, int> MapPadNumbersToNetTieGroups() const;
|
||||||
|
|
Loading…
Reference in New Issue