未验证 提交 4f117516 编写于 作者: 羽飞's avatar 羽飞 提交者: GitHub

Merge pull request #45 from hnwyllmm/main

print prompt in client on platform without readline
...@@ -26,7 +26,9 @@ public: ...@@ -26,7 +26,9 @@ public:
~DeferHelper() ~DeferHelper()
{ {
defer_(); if (defer_) {
defer_();
}
} }
private: private:
...@@ -35,8 +37,5 @@ private: ...@@ -35,8 +37,5 @@ private:
} // namespace common } // namespace common
#define AA(B, C) B##C #define DERFER_NAME(suffix) defer_helper_##suffix
#define BB(B, C) AA(B,C) #define DEFER(callback) common::DeferHelper DERFER_NAME(__LINE__)(callback)
#define DEFER(callback) common::DeferHelper BB(defer_helper_, __LINE__)(callback)
#undef AA
#undef BB
...@@ -51,6 +51,7 @@ char *my_readline(const char *prompt) ...@@ -51,6 +51,7 @@ char *my_readline(const char *prompt)
fprintf(stderr, "failed to alloc line buffer"); fprintf(stderr, "failed to alloc line buffer");
return nullptr; return nullptr;
} }
fprintf(stdout, prompt);
char *s = fgets(buffer, MAX_MEM_BUFFER_SIZE, stdin); char *s = fgets(buffer, MAX_MEM_BUFFER_SIZE, stdin);
if (nullptr == s) { if (nullptr == s) {
fprintf(stderr, "failed to read message from console"); 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.
先完成此消息的编辑!
想要评论请 注册