summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:15 +0200
committerBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:15 +0200
commit0a48c0f1af4b35338d2360f6efa4c467ec60b60d (patch)
tree406a6b1bda002889f8a99be215fcc9847dc0cb7e /src/util.cc
parent656d238d855e3d7640f10c6b0c1dc84380f50e94 (diff)
Refactor messages.cc to use boost::circular_buffer
We might as well delegate the massive implementation complexity and get rid of a ton of legacy code.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 3c358052..6dfbca65 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -2352,6 +2352,23 @@ static int complete_command(char *buf, int clen, int mlen)
}
+extern bool askfor_aux(std::string *buf, std::size_t max_len)
+{
+ // Buffer
+ char cstr[1024];
+ // Sanity
+ assert(max_len < sizeof(cstr));
+ // Copy into temporary buffer
+ cstr[buf->size()] = '\0';
+ buf->copy(cstr, std::string::npos);
+ // Delegate
+ bool result = askfor_aux(cstr, max_len);
+ // Copy back
+ (*buf) = cstr;
+ // Done
+ return result;
+}
+
/*
* Get some input at the cursor location.
* Assume the buffer is initialized to a default string.