From d5ee3296b200a7ccd863209390fe66a71b192dae Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 14 Aug 2018 10:25:20 +0200 Subject: [PATCH] Spice simulator: search each line of a text field for a Spice directive Fixes: lp:1786119 * https://bugs.launchpad.net/kicad/+bug/1786119 --- .../netlist_exporter_pspice.cpp | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index d108133b4e..bcac57ece7 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -392,38 +392,36 @@ 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() ) { - wxStringTokenizer tokenizer( text, "\r\n" ); + wxString line( tokenizer.GetNextToken() ); - while( tokenizer.HasMoreTokens() ) + if( line.StartsWith( ".inc" ) ) { - wxString directive( tokenizer.GetNextToken() ); + wxString lib = line.AfterFirst( ' ' ); - if( directive.StartsWith( ".inc" ) ) - { - wxString lib = directive.AfterFirst( ' ' ); + if( lib.IsEmpty() ) + continue; - if( !lib.IsEmpty() ) - { - // Strip quotes if present - if( ( lib.StartsWith( "\"" ) && lib.EndsWith( "\"" ) ) - || ( lib.StartsWith( "'" ) && lib.EndsWith( "'" ) ) ) - { - lib = lib.Mid( 1, lib.Length() - 2 ); - } + // Strip quotes if present + if( ( lib.StartsWith( "\"" ) && lib.EndsWith( "\"" ) ) + || ( lib.StartsWith( "'" ) && lib.EndsWith( "'" ) ) ) + { + lib = lib.Mid( 1, lib.Length() - 2 ); + } - m_libraries.insert( lib ); - } - } - else if( directive.StartsWith( ".title " ) ) - { - m_title = directive.AfterFirst( ' ' ); - } - else - { - m_directives.push_back( directive ); - } + m_libraries.insert( lib ); + } + else if( line.StartsWith( ".title " ) ) + { + m_title = line.AfterFirst( ' ' ); + } + else if( line.StartsWith( '.' ) ) + { + m_directives.push_back( line ); } } }