Spice simulator: search each line of a text field for a Spice directive

Fixes: lp:1786119
* https://bugs.launchpad.net/kicad/+bug/1786119
This commit is contained in:
Maciej Suminski 2018-08-14 10:25:20 +02:00
parent f82b839d06
commit d5ee3296b2
1 changed files with 24 additions and 26 deletions

View File

@ -392,20 +392,20 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
if( text.IsEmpty() )
continue;
if( text.GetChar( 0 ) == '.' )
{
// Analyze each line of a text field
wxStringTokenizer tokenizer( text, "\r\n" );
while( tokenizer.HasMoreTokens() )
{
wxString directive( tokenizer.GetNextToken() );
wxString line( tokenizer.GetNextToken() );
if( directive.StartsWith( ".inc" ) )
if( line.StartsWith( ".inc" ) )
{
wxString lib = directive.AfterFirst( ' ' );
wxString lib = line.AfterFirst( ' ' );
if( lib.IsEmpty() )
continue;
if( !lib.IsEmpty() )
{
// Strip quotes if present
if( ( lib.StartsWith( "\"" ) && lib.EndsWith( "\"" ) )
|| ( lib.StartsWith( "'" ) && lib.EndsWith( "'" ) ) )
@ -415,15 +415,13 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
m_libraries.insert( lib );
}
}
else if( directive.StartsWith( ".title " ) )
else if( line.StartsWith( ".title " ) )
{
m_title = directive.AfterFirst( ' ' );
m_title = line.AfterFirst( ' ' );
}
else
else if( line.StartsWith( '.' ) )
{
m_directives.push_back( directive );
}
m_directives.push_back( line );
}
}
}