mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-04 13:21:23 +00:00
Added support for backslash continuation in script files
This commit is contained in:
parent
849fd62cfe
commit
19029f377b
1 changed files with 13 additions and 2 deletions
|
@ -39,8 +39,11 @@ bool fgetline(FILE *f, std::string &buffer)
|
||||||
if (fgets(block, 4096, f) == NULL)
|
if (fgets(block, 4096, f) == NULL)
|
||||||
return false;
|
return false;
|
||||||
buffer += block;
|
buffer += block;
|
||||||
if (buffer.size() > 0 && (buffer[buffer.size()-1] == '\n' || buffer[buffer.size()-1] == '\r'))
|
if (buffer.size() > 0 && (buffer[buffer.size()-1] == '\n' || buffer[buffer.size()-1] == '\r')) {
|
||||||
|
while (buffer.size() > 0 && (buffer[buffer.size()-1] == '\n' || buffer[buffer.size()-1] == '\r'))
|
||||||
|
buffer.resize(buffer.size()-1);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +70,16 @@ static void run_frontend(std::string filename, std::string command, RTLIL::Desig
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
log_error("Can't open script file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
|
log_error("Can't open script file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
|
||||||
std::string command;
|
std::string command;
|
||||||
while (fgetline(f, command))
|
while (fgetline(f, command)) {
|
||||||
|
while (!command.empty() && command[command.size()-1] == '\\') {
|
||||||
|
std::string next_line;
|
||||||
|
if (!fgetline(f, next_line))
|
||||||
|
break;
|
||||||
|
command.resize(command.size()-1);
|
||||||
|
command += next_line;
|
||||||
|
}
|
||||||
Pass::call(design, command);
|
Pass::call(design, command);
|
||||||
|
}
|
||||||
if (!command.empty())
|
if (!command.empty())
|
||||||
Pass::call(design, command);
|
Pass::call(design, command);
|
||||||
if (filename != "-")
|
if (filename != "-")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue