Merge pull request #24 from tsion/whitespace
Fix handling of whitespace and ignore blank inputs.
This commit is contained in:
commit
a1ea85e92b
1 changed files with 5 additions and 6 deletions
11
nix-repl.cc
11
nix-repl.cc
|
@ -106,7 +106,7 @@ void NixRepl::mainLoop(const Strings & files)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!processLine(input)) return;
|
if (!removeWhitespace(input).empty() && !processLine(input)) return;
|
||||||
} catch (ParseError & e) {
|
} catch (ParseError & e) {
|
||||||
if (e.msg().find("unexpected $end") != std::string::npos) {
|
if (e.msg().find("unexpected $end") != std::string::npos) {
|
||||||
// For parse errors on incomplete input, we continue waiting for the next line of
|
// For parse errors on incomplete input, we continue waiting for the next line of
|
||||||
|
@ -178,14 +178,13 @@ bool NixRepl::getLine(string & input, const char * prompt)
|
||||||
|
|
||||||
char * s = readline(prompt);
|
char * s = readline(prompt);
|
||||||
if (!s) return false;
|
if (!s) return false;
|
||||||
string line = chomp(string(s));
|
input.append(s);
|
||||||
input.append(removeWhitespace(line));
|
|
||||||
input.push_back('\n');
|
input.push_back('\n');
|
||||||
free(s);
|
if (!removeWhitespace(s).empty()) {
|
||||||
if (line != "") {
|
add_history(s);
|
||||||
add_history(line.c_str());
|
|
||||||
append_history(1, 0);
|
append_history(1, 0);
|
||||||
}
|
}
|
||||||
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isInterrupted = 0;
|
_isInterrupted = 0;
|
||||||
|
|
Loading…
Reference in a new issue