From 489d838b6165b2cfd1091fbf1fcc9e2980138191 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(B-4.4.46a)> Date: Thu, 16 Dec 2010 21:16:52 +0100 Subject: [PATCH] Pulling out std_read_loop for libedit's fallback --- wcclparser/main.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/wcclparser/main.cpp b/wcclparser/main.cpp index 6eea080..cffc4bc 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 -- GitLab