aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2019-06-19 10:52:59 +0200
committerGitHub <noreply@github.com>2019-06-19 10:52:59 +0200
commitb3441935b1e5fd59e982870c2aa4da6036b6f30e (patch)
treeffd2e032bcdde675f6458955797c46b386cab01d
parenteb3b9fb24ac6547caa5d4063e61be600fc0d55f5 (diff)
parent4a18e19fb86f5729ca764d5b0ee338f558f90a43 (diff)
downloadyosys-b3441935b1e5fd59e982870c2aa4da6036b6f30e.tar.gz
yosys-b3441935b1e5fd59e982870c2aa4da6036b6f30e.tar.bz2
yosys-b3441935b1e5fd59e982870c2aa4da6036b6f30e.zip
Merge pull request #1100 from bwidawsk/home
Support ~ in filename parsing
-rw-r--r--backends/aiger/aiger.cc1
-rw-r--r--backends/ilang/ilang_backend.cc1
-rw-r--r--backends/json/json.cc1
-rw-r--r--backends/protobuf/protobuf.cc1
-rw-r--r--kernel/yosys.cc4
5 files changed, 8 insertions, 0 deletions
diff --git a/backends/aiger/aiger.cc b/backends/aiger/aiger.cc
index dfe506c66..d685c5638 100644
--- a/backends/aiger/aiger.cc
+++ b/backends/aiger/aiger.cc
@@ -776,6 +776,7 @@ struct AigerBackend : public Backend {
writer.write_aiger(*f, ascii_mode, miter_mode, symbols_mode);
if (!map_filename.empty()) {
+ rewrite_filename(filename);
std::ofstream mapf;
mapf.open(map_filename.c_str(), std::ofstream::trunc);
if (mapf.fail())
diff --git a/backends/ilang/ilang_backend.cc b/backends/ilang/ilang_backend.cc
index 04d1ee311..b4ba2b03f 100644
--- a/backends/ilang/ilang_backend.cc
+++ b/backends/ilang/ilang_backend.cc
@@ -483,6 +483,7 @@ struct DumpPass : public Pass {
std::stringstream buf;
if (!filename.empty()) {
+ rewrite_filename(filename);
std::ofstream *ff = new std::ofstream;
ff->open(filename.c_str(), append ? std::ofstream::app : std::ofstream::trunc);
if (ff->fail()) {
diff --git a/backends/json/json.cc b/backends/json/json.cc
index f5c687981..5022d5da1 100644
--- a/backends/json/json.cc
+++ b/backends/json/json.cc
@@ -525,6 +525,7 @@ struct JsonPass : public Pass {
std::stringstream buf;
if (!filename.empty()) {
+ rewrite_filename(filename);
std::ofstream *ff = new std::ofstream;
ff->open(filename.c_str(), std::ofstream::trunc);
if (ff->fail()) {
diff --git a/backends/protobuf/protobuf.cc b/backends/protobuf/protobuf.cc
index 549fc73ae..fff110bb0 100644
--- a/backends/protobuf/protobuf.cc
+++ b/backends/protobuf/protobuf.cc
@@ -336,6 +336,7 @@ struct ProtobufPass : public Pass {
std::stringstream buf;
if (!filename.empty()) {
+ rewrite_filename(filename);
std::ofstream *ff = new std::ofstream;
ff->open(filename.c_str(), std::ofstream::trunc);
if (ff->fail()) {
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index 377572fc2..94d6d675f 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -651,6 +651,10 @@ void rewrite_filename(std::string &filename)
filename = filename.substr(1, GetSize(filename)-2);
if (filename.substr(0, 2) == "+/")
filename = proc_share_dirname() + filename.substr(2);
+#ifndef _WIN32
+ if (filename.substr(0, 2) == "~/")
+ filename = filename.replace(0, 1, getenv("HOME"));
+#endif
}
#ifdef YOSYS_ENABLE_TCL