closing stdin closes test_core now
authorJorge Gorbe Moya <jgorbe@dsic.upv.es>
Tue, 24 Jun 2008 10:36:01 +0000 (12:36 +0200)
committerJorge Gorbe Moya <jgorbe@dsic.upv.es>
Tue, 24 Jun 2008 10:36:01 +0000 (12:36 +0200)
tests/test_core.cc

index 2d31c895ac4bb47348e0544f697928863c5c3ffa..9825de903deb9cf38900ba63689faced3ba773ec 100644 (file)
@@ -23,14 +23,14 @@ int main(int argc, char **argv)
                        
        cout << gb.status_string() << endl;
 
-       bool exit_program=false;
        string line, command, last_command;
        vector<string> arguments;
        
-       while(!exit_program)
+       while(true)
        {
                cout << "(wenboi) ";
                std::getline(cin, line, '\n');
+               if (!cin.good()) break; // if stdin is closed, exit main loop
                if (line == "") command = last_command;
                else
                {
@@ -55,7 +55,7 @@ int main(int argc, char **argv)
                }
                else if (command == "quit")
                {
-                       exit_program = true;
+                       break;
                }
                else if (command == "disasm")
                {