Fixed handling of "//" in filenames in verilog pre-processor
authorClifford Wolf <clifford@clifford.at>
Sat, 14 Feb 2015 07:41:03 +0000 (08:41 +0100)
committerClifford Wolf <clifford@clifford.at>
Sat, 14 Feb 2015 07:41:03 +0000 (08:41 +0100)
frontends/verilog/preproc.cc
frontends/verilog/verilog_lexer.l

index 4e5d165996e8ca23b23085c64f367e688b6fb8f6..e2118630e3f743bae5b4553ff75193623bdb82d9 100644 (file)
@@ -201,7 +201,7 @@ static void input_file(std::istream &f, std::string filename)
        insert_input("");
        auto it = input_buffer.begin();
 
-       input_buffer.insert(it, "`file_push " + filename + "\n");
+       input_buffer.insert(it, "`file_push \"" + filename + "\"\n");
        while ((rc = readsome(f, buffer, sizeof(buffer)-1)) > 0) {
                buffer[rc] = 0;
                input_buffer.insert(it, buffer);
index cb8fafcb28fb3f78a18fb010bb59941f02adee09..13b3e2bfc7012d3cc7470fe398606705ef1945b8 100644 (file)
@@ -85,6 +85,10 @@ YOSYS_NAMESPACE_END
        fn_stack.push_back(current_filename);
        ln_stack.push_back(frontend_verilog_yyget_lineno());
        current_filename = yytext+11;
+       if (!current_filename.empty() && current_filename.front() == '"')
+               current_filename = current_filename.substr(1);
+       if (!current_filename.empty() && current_filename.back() == '"')
+               current_filename = current_filename.substr(0, current_filename.size()-1);
        frontend_verilog_yyset_lineno(0);
 }