summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-08-09 12:00:57 +0200
committer couriersud <couriersud@gmx.org>2020-08-09 12:00:57 +0200
commit77dbc79547b7ce9163d4cdc0762b7682dfae32fc (patch)
treed5b52f0d6d490bf0ea491ed66b002389523ad7cc
parentb0b2e1351a39587a14cc5a500eabf99da772ee5d (diff)
netlist: fix line-number tracking when at end of line.
* Also remove a semicolon from nlm_opamp.cpp
-rw-r--r--src/lib/netlist/macro/nlm_opamp.cpp2
-rw-r--r--src/lib/netlist/plib/pstream.h36
-rw-r--r--src/lib/netlist/plib/ptokenizer.cpp7
3 files changed, 40 insertions, 5 deletions
diff --git a/src/lib/netlist/macro/nlm_opamp.cpp b/src/lib/netlist/macro/nlm_opamp.cpp
index 73aed0fd52b..2d0c83807d6 100644
--- a/src/lib/netlist/macro/nlm_opamp.cpp
+++ b/src/lib/netlist/macro/nlm_opamp.cpp
@@ -297,7 +297,7 @@ static NETLIST_START(MC3340_DIP)
NET_C(R17_5K1.2, D3.A, Q8.B)
NET_C(D3.K, R18_510.1)
- ALIAS(GND, R18_510.2);
+ ALIAS(GND, R18_510.2)
ALIAS(1, INPUT)
ALIAS(2, CONTROL)
diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h
index 97a4a0eea5f..ebaacfcfb73 100644
--- a/src/lib/netlist/plib/pstream.h
+++ b/src/lib/netlist/plib/pstream.h
@@ -74,6 +74,13 @@ public:
bool eof() const { return m_strm->eof(); }
+ /// \brief Read a line of UTF8 characters from the stream.
+ ///
+ /// The line will not contain a trailing linefeed
+ ///
+ /// \param line pstring reference to the result
+ /// \returns Returns false if at end of file
+ ///
bool readline(pstring &line)
{
putf8string::code_t c = 0;
@@ -96,6 +103,35 @@ public:
return true;
}
+ /// \brief Read a line of UTF8 characters from the stream including trailing linefeed.
+ ///
+ /// The line will contain the trailing linefeed
+ ///
+ /// \param line pstring reference to the result
+ /// \returns Returns false if at end of file
+ ///
+ bool readline_lf(pstring &line)
+ {
+ putf8string::code_t c = 0;
+ m_linebuf = putf8string("");
+ if (!this->readcode(c))
+ {
+ line = "";
+ return false;
+ }
+ while (true)
+ {
+ if (c != 13) // ignore CR
+ m_linebuf += putf8string(1, c);
+ if (c == 10)
+ break;
+ if (!this->readcode(c))
+ break;
+ }
+ line = m_linebuf;
+ return true;
+ }
+
bool readbyte(std::istream::char_type &b)
{
if (m_strm->eof())
diff --git a/src/lib/netlist/plib/ptokenizer.cpp b/src/lib/netlist/plib/ptokenizer.cpp
index cc3d6538f8d..ab4b0444e42 100644
--- a/src/lib/netlist/plib/ptokenizer.cpp
+++ b/src/lib/netlist/plib/ptokenizer.cpp
@@ -48,7 +48,7 @@ namespace plib {
if (m_px == m_cur_line.end())
{
//++m_source_location.back();
- if (m_strm->readline(m_cur_line))
+ if (m_strm->readline_lf(m_cur_line))
{
m_px = m_cur_line.begin();
if (*m_px != '#')
@@ -56,7 +56,6 @@ namespace plib {
}
else
return 0;
- return '\n';
}
pstring::value_type c = *(m_px++);
return c;
@@ -169,7 +168,7 @@ namespace plib {
if (ret.str() == "1")
benter = true;
if (ret.str() == "2")
- bexit = false;
+ bexit = true;
// FIXME: process flags; actually only 1 (file enter) and 2 (after file exit)
ret = get_token_queue();
}
@@ -177,7 +176,7 @@ namespace plib {
m_source_location.pop_back();
if (!benter) // new location!
m_source_location.pop_back();
- m_source_location.emplace_back(plib::source_location(file, lineno));
+ m_source_location.emplace_back(plib::source_location(file, lineno - 1));
}
else if (ret.is_type(token_type::SOURCELINE))
{