aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-04-16 17:18:29 +0000
committerGitHub <noreply@github.com>2020-04-16 17:18:29 +0000
commitc2804a68c2d4d198e72be7a8c0164093c1e62fce (patch)
tree24a367fc1c275c44c0d7cc7a31644d12a903265f /kernel
parent7a434cdd7baf4ffdac5497c3e6783f2bb0e0bac6 (diff)
parent76c9e1c26505894546610cb06ff9a861c1be5859 (diff)
downloadyosys-c2804a68c2d4d198e72be7a8c0164093c1e62fce.tar.gz
yosys-c2804a68c2d4d198e72be7a8c0164093c1e62fce.tar.bz2
yosys-c2804a68c2d4d198e72be7a8c0164093c1e62fce.zip
Merge pull request #1896 from boqwxp/read_stdin_repl
Frontend: allow reading file input from stdin, like a REPL heredoc mode
Diffstat (limited to 'kernel')
-rw-r--r--kernel/register.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/register.cc b/kernel/register.cc
index af8c1b8e8..925d0d776 100644
--- a/kernel/register.cc
+++ b/kernel/register.cc
@@ -485,20 +485,21 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
cmd_error(args, argidx, "Extra filename argument in direct file mode.");
filename = arg;
+ //Accommodate heredocs with EOT marker spaced out from "<<", e.g. "<< EOT" vs. "<<EOT"
if (filename == "<<" && argidx+1 < args.size())
filename += args[++argidx];
if (filename.compare(0, 2, "<<") == 0) {
- if (Frontend::current_script_file == NULL)
- log_error("Unexpected here document '%s' outside of script!\n", filename.c_str());
if (filename.size() <= 2)
log_error("Missing EOT marker in here document!\n");
std::string eot_marker = filename.substr(2);
+ if (Frontend::current_script_file == nullptr)
+ filename = "<stdin>";
last_here_document.clear();
while (1) {
std::string buffer;
char block[4096];
while (1) {
- if (fgets(block, 4096, 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'))