Просмотр исходного кода

Allow using Ctrl-D to quit the REPL

Without this, `std::getline` fails silently and this loops infinitely
printing the prompt.
Max Bernstein 3 лет назад
Родитель
Сommit
9a4c9940d5
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/main.cpp

+ 3 - 1
src/main.cpp

@@ -30,7 +30,9 @@ int main(int argc, char** argv){
         while(true){
             (*vm->_stdout) << (need_more_lines ? "... " : ">>> ");
             std::string line;
-            std::getline(std::cin, line);
+            if (!std::getline(std::cin, line)) {
+                break;
+            }
             need_more_lines = pkpy_repl_input(repl, line.c_str());
         }
         pkpy_delete(vm);