diff --git a/wcclparser/main.cpp b/wcclparser/main.cpp index 6eea0802fc33762a04f7f5dcc66e381e8b5c5841..cffc4bcb9dde84e72e961ec72cf44979d0f181e6 100644 --- a/wcclparser/main.cpp +++ b/wcclparser/main.cpp @@ -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