diff options
author | 2020-08-09 12:00:57 +0200 | |
---|---|---|
committer | 2020-08-09 12:00:57 +0200 | |
commit | 77dbc79547b7ce9163d4cdc0762b7682dfae32fc (patch) | |
tree | d5b52f0d6d490bf0ea491ed66b002389523ad7cc /src/lib/netlist/plib/pstream.h | |
parent | b0b2e1351a39587a14cc5a500eabf99da772ee5d (diff) |
netlist: fix line-number tracking when at end of line.
* Also remove a semicolon from nlm_opamp.cpp
Diffstat (limited to 'src/lib/netlist/plib/pstream.h')
-rw-r--r-- | src/lib/netlist/plib/pstream.h | 36 |
1 files changed, 36 insertions, 0 deletions
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()) |