From bc27b0ed5f04f2d01e50ffb7569acc420cc4188c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 9 Jun 2019 17:46:02 +0200 Subject: [PATCH] Sim spice: fix unescaped netnames in spice netlist and simulator dialogs. Net names in eeschema that include '/' are escaped ('/' replaced by "{slash}") Escaped netnames are only for internal use, and must be unescaped in spice netlist and dialogs. --- eeschema/dialogs/dialog_signal_list.cpp | 7 +++++-- eeschema/netlist_exporters/netlist_exporter_pspice.cpp | 3 +++ eeschema/sim/netlist_exporter_pspice_sim.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/eeschema/dialogs/dialog_signal_list.cpp b/eeschema/dialogs/dialog_signal_list.cpp index 602ff5f15a..425e69f801 100644 --- a/eeschema/dialogs/dialog_signal_list.cpp +++ b/eeschema/dialogs/dialog_signal_list.cpp @@ -54,8 +54,11 @@ bool DIALOG_SIGNAL_LIST::TransferDataToWindow() // Voltage list for( const auto& net : m_exporter->GetNetIndexMap() ) { - if( net.first != "GND" && net.first != "0" ) - m_signals->Append( wxString::Format( "V(%s)", net.first ) ); + // netnames are escaped (can contain "{slash}" for '/') Unscape them: + wxString netname = UnescapeString( net.first ); + + if( netname != "GND" && netname != "0" ) + m_signals->Append( wxString::Format( "V(%s)", netname ) ); } auto simType = m_exporter->GetSimType(); diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index ec006d39e3..3aa56f5350 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -150,6 +150,9 @@ bool NETLIST_EXPORTER_PSPICE::Format( OUTPUTFORMATTER* aFormatter, unsigned aCtl // Replace parenthesis with underscore to prevent parse issues with simulators ReplaceForbiddenChars( netName ); + // unescape net names that contain a escaped sequence ("{slash}"): + netName = UnescapeString( netName ); + // Add quotes to nets containing slashes. This isn't added to ReplaceForbidenChars // because this is only necessary for file writing; nets with slashes can be // handled by ngspice after loading. diff --git a/eeschema/sim/netlist_exporter_pspice_sim.cpp b/eeschema/sim/netlist_exporter_pspice_sim.cpp index 3178c8dd1a..9dfea34a2c 100644 --- a/eeschema/sim/netlist_exporter_pspice_sim.cpp +++ b/eeschema/sim/netlist_exporter_pspice_sim.cpp @@ -36,13 +36,15 @@ wxString NETLIST_EXPORTER_PSPICE_SIM::GetSpiceVector( const wxString& aName, SIM if( aType & SPT_VOLTAGE ) { + // netnames are escaped (can contain "{slash}" for '/') Unscape them: + wxString spicenet = UnescapeString( aName ); + // Spice netlist netnames does not accept some chars, whicyh are replaced // by eeschema netlist generator. // Replace these forbidden chars to find the actual spice net name - wxString spicenet = aName; NETLIST_EXPORTER_PSPICE::ReplaceForbiddenChars( spicenet ); - return wxString::Format( "V(%s)", spicenet.GetData() ); + return wxString::Format( "V(%s)", spicenet ); } else if( aType & SPT_CURRENT )