Browse Source

Enforce spice-valid netnames when parsing

Avoids prematurely trimming netnames containing numbers

Fixes https://gitlab.com/kicad/code/kicad/issues/18598
master
Seth Hillbrand 4 weeks ago
parent
commit
d6d476e39e
  1. 53
      eeschema/sim/simulator_frame_ui.cpp

53
eeschema/sim/simulator_frame_ui.cpp

@ -2095,6 +2095,32 @@ void SIMULATOR_FRAME_UI::applyUserDefinedSignals()
{
std::vector<bool> mask( aExpression.length(), false );
auto isNetnameChar = []( wxUniChar aChar ) -> bool
{
wxUint32 value = aChar.GetValue();
if( ( value >= '0' && value <= '9' ) || ( value >= 'A' && value <= 'Z' )
|| ( value >= 'a' && value <= 'z' ) )
{
return true;
}
switch( value )
{
case '_':
case '/':
case '+':
case '-':
case '~':
case '.':
return true;
default:
break;
}
return false;
};
for( const auto& netname : m_netnames )
{
size_t pos = aExpression.find( netname );
@ -2109,6 +2135,33 @@ void SIMULATOR_FRAME_UI::applyUserDefinedSignals()
}
}
for( size_t i = 0; i < aExpression.length(); ++i )
{
if( !mask[i] || ( i > 0 && mask[i - 1] ) )
continue;
size_t j = i + 1;
while( j < aExpression.length() )
{
if( mask[j] )
{
++j;
continue;
}
if( isNetnameChar( aExpression[j] ) )
{
mask[j] = true;
++j;
}
else
{
break;
}
}
}
wxString quotedNetnames = "";
bool startQuote = true;

Loading…
Cancel
Save