Skip to content

Commit

Permalink
Merge pull request #1075 from YosysHQ/gatecat/ecp5-lpf-errors
Browse files Browse the repository at this point in the history
ecp5: Improve error handling for missing end-"
  • Loading branch information
gatecat committed Jan 2, 2023
2 parents 3338227 + d210a5a commit 5cea801
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ecp5/lpf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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('#');
Expand Down

0 comments on commit 5cea801

Please sign in to comment.