Fix a bug in handling quotes in multi-cmd lines in Yosys scripts
authorClifford Wolf <clifford@clifford.at>
Tue, 12 Mar 2019 20:14:50 +0000 (21:14 +0100)
committerClifford Wolf <clifford@clifford.at>
Tue, 12 Mar 2019 20:15:11 +0000 (21:15 +0100)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
kernel/yosys.cc

index 6fd53f85e0770886e7b56b045a40ea1111bc26b8..450e4e4cfba7be82e1d8987279fd50f1fbdb8811 100644 (file)
@@ -218,12 +218,18 @@ std::string next_token(std::string &text, const char *sep, bool long_strings)
 
        if (long_strings && pos_begin != text.size() && text[pos_begin] == '"') {
                string sep_string = sep;
-               for (size_t i = pos_begin+1; i < text.size(); i++)
+               for (size_t i = pos_begin+1; i < text.size(); i++) {
                        if (text[i] == '"' && (i+1 == text.size() || sep_string.find(text[i+1]) != std::string::npos)) {
                                std::string token = text.substr(pos_begin, i-pos_begin+1);
                                text = text.substr(i+1);
                                return token;
                        }
+                       if (i+1 < text.size() && text[i] == '"' && text[i+1] == ';' && (i+2 == text.size() || sep_string.find(text[i+2]) != std::string::npos)) {
+                               std::string token = text.substr(pos_begin, i-pos_begin+1);
+                               text = text.substr(i+2);
+                               return token + ";";
+                       }
+               }
        }
 
        size_t pos_end = text.find_first_of(sep, pos_begin);