diff --git a/src/db/db/dbNetlistSpiceReader.cc b/src/db/db/dbNetlistSpiceReader.cc index 2ad1c14e4..7f92bcf8b 100644 --- a/src/db/db/dbNetlistSpiceReader.cc +++ b/src/db/db/dbNetlistSpiceReader.cc @@ -633,6 +633,13 @@ SpiceCircuitDict::get_line () } else if (ex.test_without_case (".endl")) { + std::string name; + if (ex.try_read_name (name)) { + if (! m_in_lib.empty () && mp_netlist->normalize_name (name) != m_in_lib.back ()) { + warn (tl::sprintf (tl::to_string (tr (".endl has wrong name: %s given, %s expected")), mp_netlist->normalize_name (name), m_in_lib.back ())); + } + } + if (! m_in_lib.empty ()) { m_in_lib.pop_back (); } else { diff --git a/src/db/unit_tests/dbNetlistReaderTests.cc b/src/db/unit_tests/dbNetlistReaderTests.cc index c571065a3..fdb68e873 100644 --- a/src/db/unit_tests/dbNetlistReaderTests.cc +++ b/src/db/unit_tests/dbNetlistReaderTests.cc @@ -836,6 +836,28 @@ TEST(21_lib) ); } +// issue #1681, .endl with lib name +TEST(22_endl) +{ + db::Netlist nl; + + std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader22.cir"); + + db::NetlistSpiceReader reader; + tl::InputStream is (path); + reader.read (is, nl); + + EXPECT_EQ (nl.to_string (), + "circuit .TOP ();\n" + " device CAP '10' (A='1',B='2') (C=1e-12,A=0,P=0);\n" + " device CAP '1' (A='1',B='2') (C=1e-10,A=0,P=0);\n" + " device CAP '2A' (A='1',B='2') (C=1.01e-10,A=0,P=0);\n" + " device CAP '2B' (A='1',B='2') (C=1.02e-10,A=0,P=0);\n" + " device CAP '100' (A='1',B='2') (C=1.5e-11,A=0,P=0);\n" + "end;\n" + ); +} + TEST(100_ExpressionParser) { std::map vars; diff --git a/testdata/algo/nreader22.cir b/testdata/algo/nreader22.cir new file mode 100644 index 000000000..335ee3ae9 --- /dev/null +++ b/testdata/algo/nreader22.cir @@ -0,0 +1,6 @@ + +.lib nreader22_lib1.cir lib1 +.lib nreader22_lib1.cir lib2 + +C100 1 2 15p + diff --git a/testdata/algo/nreader22_inc.cir b/testdata/algo/nreader22_inc.cir new file mode 100644 index 000000000..4dc60c6b2 --- /dev/null +++ b/testdata/algo/nreader22_inc.cir @@ -0,0 +1,4 @@ + +C2a 1 2 101p +C2b 1 2 102p + diff --git a/testdata/algo/nreader22_lib1.cir b/testdata/algo/nreader22_lib1.cir new file mode 100644 index 000000000..87d1c3377 --- /dev/null +++ b/testdata/algo/nreader22_lib1.cir @@ -0,0 +1,10 @@ + +.lib lib1 +.lib nreader22_lib2.cir lib3 +C1 1 2 100p +.endl lib1 + +.lib lib2 +.include nreader22_inc.cir +.endl lib2 + diff --git a/testdata/algo/nreader22_lib2.cir b/testdata/algo/nreader22_lib2.cir new file mode 100644 index 000000000..03e71861e --- /dev/null +++ b/testdata/algo/nreader22_lib2.cir @@ -0,0 +1,11 @@ + +.lib lib3 +C10 1 2 1p +.endl lib3 + +C11 1 2 1.5p + +.lib lib4 +C12 1 2 42p +.endl lib4 +