From: Clifford Wolf Date: Thu, 6 Feb 2014 00:28:33 +0000 (+0100) Subject: Added support for backslash continuation in script files X-Git-Tag: yosys-0.2.0~75 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19029f377b0866c1ac1a3c2879c445d4ac3cdd82;p=yosys.git Added support for backslash continuation in script files --- diff --git a/kernel/driver.cc b/kernel/driver.cc index 6d139f197..d31d36b2d 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -39,8 +39,11 @@ bool fgetline(FILE *f, std::string &buffer) if (fgets(block, 4096, f) == NULL) return false; 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; + } } } @@ -67,8 +70,16 @@ static void run_frontend(std::string filename, std::string command, RTLIL::Desig if (f == NULL) log_error("Can't open script file `%s' for reading: %s\n", filename.c_str(), strerror(errno)); 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); + } if (!command.empty()) Pass::call(design, command); if (filename != "-")