Fix infinite loop in abc command under emscripten
authorRobert Ou <rqou@robertou.com>
Tue, 14 Nov 2017 12:08:36 +0000 (04:08 -0800)
committerRobert Ou <rqou@robertou.com>
Sat, 19 May 2018 05:42:39 +0000 (22:42 -0700)
passes/techmap/abc.cc

index 8e148430188b510eb3e0cffc1d90a9e125fd540e..18868c6d77208b84fd3c22f7069c1ce0c7385514 100644 (file)
@@ -550,11 +550,13 @@ std::string replace_tempdir(std::string text, std::string tempdir_name, bool sho
        }
 
        std::string  selfdir_name = proc_self_dirname();
-       while (1) {
-               size_t pos = text.find(selfdir_name);
-               if (pos == std::string::npos)
-                       break;
-               text = text.substr(0, pos) + "<yosys-exe-dir>/" + text.substr(pos + GetSize(selfdir_name));
+       if (selfdir_name != "/") {
+               while (1) {
+                       size_t pos = text.find(selfdir_name);
+                       if (pos == std::string::npos)
+                               break;
+                       text = text.substr(0, pos) + "<yosys-exe-dir>/" + text.substr(pos + GetSize(selfdir_name));
+               }
        }
 
        return text;