Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/verilog/verilog_preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,9 @@ void verilog_preprocessort::include(
const std::string &filename,
const source_locationt &source_location)
{
{
filet tmp_file;
files.push_back(tmp_file);
}

files.emplace_back(true, nullptr, filename);
filet &file=files.back();

file.filename=filename;
file.close=true;

file.in=new std::ifstream(filename.c_str());
if(*file.in) return;

Expand Down Expand Up @@ -252,12 +245,7 @@ Function: verilog_preprocessort::preprocessor

void verilog_preprocessort::preprocessor()
{
{
filet file;
file.in=∈
file.filename=filename;
files.push_back(file);
}
files.emplace_back(false, &in, filename);

while(!files.empty())
{
Expand Down
13 changes: 11 additions & 2 deletions src/verilog/verilog_preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,17 @@ class verilog_preprocessort:public preprocessort
std::istream *in;
std::string filename;
unsigned line, last_line;

filet() { close=false; line=1; last_line=0; column=1; }

filet(bool _close, std::istream *_in, std::string _filename)
: close(_close),
in(_in),
filename(std::move(_filename)),
line(1),
last_line(0),
column(1)
{
}

~filet() { if(close) delete in; }

bool get(char &ch);
Expand Down