From 87e6649fc30a37adabf384a68f588de946bc3468 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Tue, 23 Feb 2016 18:29:56 -0600 Subject: [PATCH 1/2] Fix handling of whitespace. Whitespace will no longer be removed from input lines, which fixes pasting multiline strings containing end-of-line or beginning-of-line whitespace. --- nix-repl.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nix-repl.cc b/nix-repl.cc index 577efa8e2..1cdff20fd 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -178,14 +178,13 @@ bool NixRepl::getLine(string & input, const char * prompt) char * s = readline(prompt); if (!s) return false; - string line = chomp(string(s)); - input.append(removeWhitespace(line)); + input.append(s); input.push_back('\n'); - free(s); - if (line != "") { - add_history(line.c_str()); + if (!removeWhitespace(s).empty()) { + add_history(s); append_history(1, 0); } + free(s); } _isInterrupted = 0; From 38816759fc7f70605ecfd73304b9d442db388b78 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Tue, 23 Feb 2016 18:30:21 -0600 Subject: [PATCH 2/2] Ignore blank inputs. Previously, nix-repl would consider this an incomplete parse and wait for the next line as if it was a multiline input. Blank lines in the middle of a multiline input will continue to work. --- nix-repl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix-repl.cc b/nix-repl.cc index 1cdff20fd..6f4287a2b 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -106,7 +106,7 @@ void NixRepl::mainLoop(const Strings & files) } try { - if (!processLine(input)) return; + if (!removeWhitespace(input).empty() && !processLine(input)) return; } catch (ParseError & e) { if (e.msg().find("unexpected $end") != std::string::npos) { // For parse errors on incomplete input, we continue waiting for the next line of