提交 2500a791 编写于 作者: 羽飞's avatar 羽飞

print prompt in client on platform without readline

上级 45e5cb77
......@@ -26,8 +26,10 @@ public:
~DeferHelper()
{
if (defer_) {
defer_();
}
}
private:
const std::function<void()> defer_;
......@@ -35,8 +37,5 @@ private:
} // namespace common
#define AA(B, C) B##C
#define BB(B, C) AA(B,C)
#define DEFER(callback) common::DeferHelper BB(defer_helper_, __LINE__)(callback)
#undef AA
#undef BB
#define DERFER_NAME(suffix) defer_helper_##suffix
#define DEFER(callback) common::DeferHelper DERFER_NAME(__LINE__)(callback)
......@@ -51,6 +51,7 @@ char *my_readline(const char *prompt)
fprintf(stderr, "failed to alloc line buffer");
return nullptr;
}
fprintf(stdout, prompt);
char *s = fgets(buffer, MAX_MEM_BUFFER_SIZE, stdin);
if (nullptr == s) {
fprintf(stderr, "failed to read message from console");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册