diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index 11d8cbe50d..4115e214ee 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -384,6 +384,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) m_directives.clear(); bool controlBlock = false; + bool circuitBlock = false; for( unsigned i = 0; i < sheetList.size(); i++ ) { @@ -436,20 +437,9 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) m_title = line.AfterFirst( ' ' ); } - // Handle .control .. .endc blocks - else if( lowercaseline.IsSameAs( ".control" ) && ( !controlBlock ) ) - { - controlBlock = true; - m_directives.push_back( line ); - } - else if( lowercaseline.IsSameAs( ".endc" ) && controlBlock ) - { - controlBlock = false; - m_directives.push_back( line ); - } - else if( line.StartsWith( '.' ) // one-line directives || controlBlock // .control .. .endc block + || circuitBlock // .subckt .. .ends block || couplingK.Matches( line ) // K## L## L## coupling constant || ( directiveStarted && line.StartsWith( '+' ) ) ) // multiline directives { @@ -458,6 +448,21 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) m_directives.emplace_back( line + " " ); } + + // Handle .control .. .endc blocks + if( lowercaseline.IsSameAs( ".control" ) && ( !controlBlock ) ) + controlBlock = true; + + if( lowercaseline.IsSameAs( ".endc" ) && controlBlock ) + controlBlock = false; + + // Handle .subckt .. .ends blocks + if( lowercaseline.StartsWith( ".subckt" ) && ( !circuitBlock ) ) + circuitBlock = true; + + if( lowercaseline.IsSameAs( ".ends" ) && circuitBlock ) + circuitBlock = false; + // Mark directive as started or continued in case it is a multi-line one directiveStarted = line.StartsWith( '.' ) || ( directiveStarted && line.StartsWith( '+' ) );