diff --git a/planning/src/RS/rsCheck.cpp b/planning/src/RS/rsCheck.cpp index 3973bc90..67220c7d 100644 --- a/planning/src/RS/rsCheck.cpp +++ b/planning/src/RS/rsCheck.cpp @@ -1,6 +1,7 @@ #include "RS/rsCheck.h" #include "file_io/pln_blif_file.h" #include "file_io/pln_csv_reader.h" +#include namespace pln { @@ -117,8 +118,13 @@ bool do_check_blif(CStr cfn, lprintf(" # WARNINGS= %u", numWarn); lputs(); if (numWarn or ::getenv("pln_always_write_blif")) { - string outFn = str::concat("PLN_W", std::to_string(numWarn), "_", cfn); + std::filesystem::path full_path{bfile.fnm_}; + std::filesystem::path base_path = full_path.filename(); + std::string base = base_path.string(); + string outFn = str::concat("PLN_W", std::to_string(numWarn), "_", base); + string wr_ok = bfile.writeBlif(outFn, numWarn); + if (wr_ok.empty()) lprintf("---!! FAILED writeBlif to '%s'\n", outFn.c_str()); else diff --git a/planning/src/file_io/pln_blif_file.cpp b/planning/src/file_io/pln_blif_file.cpp index 947de344..fa2612d7 100644 --- a/planning/src/file_io/pln_blif_file.cpp +++ b/planning/src/file_io/pln_blif_file.cpp @@ -306,7 +306,7 @@ bool BLIF_file::readBlif() noexcept { } size_t num_escaped = escapeNL(); - if (trace_ >= 4) { + if (trace_ >= 6) { lprintf(" ....\\ ... num_escaped= %zu\n", num_escaped); } @@ -2509,7 +2509,12 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept { if (not hasLines()) return {}; - string fn2 = (toFn == fnm_ ? str::concat("2_", toFn) : toFn); + string fn2 = toFn; // (toFn == fnm_ ? str::concat("2_", toFn) : toFn); + + if (trace_ >= 4) { + lout() << "pln_blif_file: writing BLIF to " << fn2 + << "\n CWD= " << get_CWD() << endl; + } CStr cnm = fn2.c_str(); FILE* f = ::fopen(cnm, "w"); @@ -2562,7 +2567,7 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept { buf[0] = 0; buf[1] = 0; size_t rdsz = dNode.realData_.size(); if (trace_ >= 4) { - lprintf("wrBlif: cell %s at line %zu has dangling bit, filtering..\n", + lprintf(" wrBlif: cell %s at line %zu has dangling bit, filtering..\n", dNode.cPrimType(), lineNum); if (trace_ >= 5) { lprintf(" dangling cell realData_.size()= %zu\n", rdsz); @@ -2581,7 +2586,7 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept { tail = ::stpcpy(tail, ts); } if (trace_ >= 4) { - lprintf("wrBlif: filtered dangling bits (%u) for cell %s at line %zu\n", + lprintf(" wrBlif: filtered dangling bits (%u) for cell %s at line %zu\n", skipCnt, dNode.cPrimType(), lineNum); } } @@ -2617,6 +2622,8 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept { flush_out(trace_ >= 5); + if (error) + return {}; return fn2; } diff --git a/planning/src/main.cpp b/planning/src/main.cpp index e505da56..4701aa5d 100644 --- a/planning/src/main.cpp +++ b/planning/src/main.cpp @@ -1,4 +1,4 @@ -static const char* _pln_VERSION_STR = "pln0355"; +static const char* _pln_VERSION_STR = "pln0356"; #include "RS/rsEnv.h" #include "util/pln_log.h" diff --git a/planning/src/util/pln_log.h b/planning/src/util/pln_log.h index b7ca5c59..7a6fb2f1 100644 --- a/planning/src/util/pln_log.h +++ b/planning/src/util/pln_log.h @@ -156,10 +156,18 @@ inline string concat(CStr a, const string& b, CStr c, CStr d) noexcept { if (a) z = a; z += b; - if (c) - z += c; - if (d) - z += d; + if (c) z += c; + if (d) z += d; + return z; +} +inline string concat(CStr a, const string& b, CStr c, const string& d) noexcept { + string z; + z.reserve(p_strlen(a) + b.length() + p_strlen(c) + d.length() + 1); + if (a) + z = a; + z += b; + if (c) z += c; + z += d; return z; } inline string concat(const string& a, CStr b) noexcept { return b ? a + b : a; }