ENH: setSet : proper exit upon eof

This commit is contained in:
mattijs
2010-10-25 12:22:25 +01:00
parent df4dc659d7
commit 6261ef058b

View File

@ -934,18 +934,31 @@ int main(int argc, char *argv[])
{ {
char* linePtr = readline("readline>"); char* linePtr = readline("readline>");
rawLine = string(linePtr); if (linePtr)
if (*linePtr)
{ {
add_history(linePtr); rawLine = string(linePtr);
write_history(historyFile);
}
free(linePtr); // readline uses malloc, not new. if (*linePtr)
{
add_history(linePtr);
write_history(historyFile);
}
free(linePtr); // readline uses malloc, not new.
}
else
{
break;
}
} }
# else # else
{ {
if (!std::cin.good())
{
Info<< "End of cin" << endl;
// No error.
break;
}
Info<< "Command>" << flush; Info<< "Command>" << flush;
std::getline(std::cin, rawLine); std::getline(std::cin, rawLine);
} }