Refined solution for issue-245 by providing a better name mapping (checked with ngspice)

This commit is contained in:
Matthias Koefferlein 2019-03-22 00:05:17 +01:00
parent 9356f32026
commit e545d6af3f
2 changed files with 14 additions and 5 deletions

View File

@ -246,12 +246,21 @@ std::string NetlistSpiceWriter::net_to_string (const db::Net *net) const
} else {
// Tested with ngspice: this tool likes in net names: . $ ! & \ # + : | (but not at beginning)
// It does not like: , ;
// We translate , to | for the net separator
std::string n = net->expanded_name ();
std::string nn;
nn.reserve (n.size ());
nn.reserve (n.size () + 1);
if (!isalnum (*n.c_str ())) {
nn += "\\";
}
for (const char *cp = n.c_str (); *cp; ++cp) {
if (isspace (*cp)) {
nn += tl::sprintf ("$x%02x", (unsigned char) *cp);
if (! isalnum (*cp) && strchr (".$!&\\#+:,", *cp) == 0) {
nn += tl::sprintf ("\\x%02x", (unsigned char) *cp);
} else if (*cp == ',') {
nn += "|";
} else {
nn += *cp;
}

View File

@ -11,9 +11,9 @@ XSC1 n1 n2 C1
* cell C1
* pin p1
* pin p2
.SUBCKT C1 N1 N$x202
.SUBCKT C1 N1 N\x202
* device instance $1 0,0 XCLS
XD_$1 N1 n3 XCLS PARAMS: U=-17 V=42
* device instance $2 0,0 XCLS
XD_$2 n3 N$x202 XCLS PARAMS: U=17 V=-42
XD_$2 n3 N\x202 XCLS PARAMS: U=17 V=-42
.ENDS C1