From: Alberto Gonzalez Date: Fri, 10 Apr 2020 20:06:12 +0000 (+0000) Subject: Use script-style heredoc syntax for REPL heredocs. X-Git-Tag: working-ls180~629^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76c9e1c26505894546610cb06ff9a861c1be5859;p=yosys.git Use script-style heredoc syntax for REPL heredocs. --- diff --git a/kernel/register.cc b/kernel/register.cc index ad9d0ac94..925d0d776 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -479,27 +479,27 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector" : arg; + filename = arg; //Accommodate heredocs with EOT marker spaced out from "<<", e.g. "<< EOT" vs. "<") { - if (Frontend::current_script_file == NULL && filename != "") - log_error("Unexpected here document '%s' outside of script!\n", filename.c_str()); + if (filename.compare(0, 2, "<<") == 0) { if (filename.size() <= 2) log_error("Missing EOT marker in here document!\n"); - std::string eot_marker = filename == ""? "EOT" : filename.substr(2); //"EOT" hardcoded as EOT marker when reading from stdin + std::string eot_marker = filename.substr(2); + if (Frontend::current_script_file == nullptr) + filename = ""; last_here_document.clear(); while (1) { std::string buffer; char block[4096]; while (1) { - if (fgets(block, 4096, filename == ""? stdin : Frontend::current_script_file) == NULL) + if (fgets(block, 4096, Frontend::current_script_file == nullptr? stdin : Frontend::current_script_file) == nullptr) log_error("Unexpected end of file in here document '%s'!\n", filename.c_str()); buffer += block; if (buffer.size() > 0 && (buffer[buffer.size() - 1] == '\n' || buffer[buffer.size() - 1] == '\r'))