Skip to content
Snippets Groups Projects
Commit 489d838b authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Pulling out std_read_loop for libedit's fallback

parent 1fde16fb
Branches
No related merge requests found
......@@ -32,6 +32,18 @@ namespace {
const char* _prompt = "Enter any operator expression: ";
}
void std_read_loop(boost::function<bool (const std::string&)>& line_cb)
{
while (std::cin.good()) {
std::cout << _prompt << std::flush;
std::string s;
getline(std::cin, s);
if (line_cb(s)) {
return;
}
}
}
#if defined(HAVE_LIBEDIT) && !defined(_WINDOWS) //non-Windows libedit read loop
const char* query_prompt(EditLine*) {
......@@ -122,16 +134,10 @@ void read_loop(boost::function<bool (const std::string&)>& line_cb)
#else // standard io read loop
inline
void read_loop(boost::function<bool (const std::string&)>& line_cb)
{
while (std::cin.good()) {
std::cout << _prompt << std::flush;
std::string s;
getline(std::cin, s);
if (line_cb(s)) {
return;
}
}
std_read_loop(line_cb);
}
#endif
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment