From f55f9a522b44a3cae5c470db79aa663e3eb17d1a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 9 Jul 2021 12:54:45 +0200 Subject: [PATCH] Netlist exporter spice: expand env vars when used in include library name. --- .../netlist_exporters/netlist_exporter_pspice.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index 0e56ba630e..dbe677d41a 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -94,25 +95,27 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl aFormatter->Print( 0, ".title %s\n", TO_UTF8( m_title ) ); // Write .include directives - for( const wxString& lib : m_libraries ) + for( const wxString& curr_lib : m_libraries ) { + // First, expand env vars, if any + wxString libname = ExpandEnvVarSubstitutions( curr_lib, &m_schematic->Prj() ); wxString full_path; if( ( aCtl & NET_ADJUST_INCLUDE_PATHS ) ) { // Look for the library in known search locations - full_path = ResolveFile( lib, &Pgm().GetLocalEnvVariables(), &m_schematic->Prj() ); + full_path = ResolveFile( libname, &Pgm().GetLocalEnvVariables(), &m_schematic->Prj() ); if( full_path.IsEmpty() ) { DisplayError( nullptr, wxString::Format( _( "Could not find library file %s." ), - lib ) ); - full_path = lib; + libname ) ); + full_path = libname; } } else { - full_path = lib; // just use the unaltered path + full_path = libname; // just use the unaltered path } aFormatter->Print( 0, ".include \"%s\"\n", TO_UTF8( full_path ) );