diff options
author | myrtle <gatecat@ds0.me> | 2023-01-02 09:25:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-02 09:25:14 +0100 |
commit | 5cea801a2fdb71a23b2ccfe1b64e95cfa34d6242 (patch) | |
tree | 21d49015ea740e8cf6f41531d8b7fd3d181d3ccc | |
parent | 3338227ef7d10b8a35980c5274df1fdfd3098f31 (diff) | |
parent | d210a5adeda40ac1b63b033e4a9f8c7c2217f2ef (diff) | |
download | nextpnr-5cea801a2fdb71a23b2ccfe1b64e95cfa34d6242.tar.gz nextpnr-5cea801a2fdb71a23b2ccfe1b64e95cfa34d6242.tar.bz2 nextpnr-5cea801a2fdb71a23b2ccfe1b64e95cfa34d6242.zip |
Merge pull request #1075 from YosysHQ/gatecat/ecp5-lpf-errors
ecp5: Improve error handling for missing end-"
-rw-r--r-- | ecp5/lpf.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ecp5/lpf.cc b/ecp5/lpf.cc index 70ebfe81..4f02d22d 100644 --- a/ecp5/lpf.cc +++ b/ecp5/lpf.cc @@ -44,21 +44,22 @@ bool Arch::apply_lpf(std::string filename, std::istream &in) auto isempty = [](const std::string &str) { return std::all_of(str.begin(), str.end(), [](char c) { return isblank(c) || c == '\r' || c == '\n'; }); }; - auto strip_quotes = [](const std::string &str) { - if (str.at(0) == '"') { - NPNR_ASSERT(str.back() == '"'); - return str.substr(1, str.size() - 2); - } else { - return str; - } - }; - try { if (!in) log_error("failed to open LPF file\n"); std::string line; std::string linebuf; int lineno = 0; + auto strip_quotes = [&](const std::string &str) { + if (str.at(0) == '"') { + if (str.back() != '"') { + log_error("expected '\"' at end of string '%s' (on line %d)\n", str.c_str(), lineno); + } + return str.substr(1, str.size() - 2); + } else { + return str; + } + }; while (std::getline(in, line)) { ++lineno; size_t cstart = line.find('#'); |