From a165b42575bb0b1236a68bbafac787aac13ca0c7 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 10 Sep 2018 21:45:34 +0300 Subject: [PATCH] Minor fixes. GitOrigin-RevId: 793bc74ee1c82b5a86e044be65e4be0e5ce00336 --- td/telegram/cli.cpp | 3 ++- tdutils/td/utils/port/StdStreams.cpp | 9 +++++++++ tdutils/td/utils/port/StdStreams.h | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index ca989d3a..14b668bf 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include // for strcmp #include @@ -3424,7 +3425,7 @@ class CliClient final : public Actor { int stdin_getc() { auto slice = stdin_.input_buffer().prepare_read(); if (slice.empty()) { - return 0; + return EOF; } int res = slice[0]; stdin_.input_buffer().confirm_read(1); diff --git a/tdutils/td/utils/port/StdStreams.cpp b/tdutils/td/utils/port/StdStreams.cpp index 3deb4a9f..1bc188a3 100644 --- a/tdutils/td/utils/port/StdStreams.cpp +++ b/tdutils/td/utils/port/StdStreams.cpp @@ -55,6 +55,10 @@ class BufferedStdinImpl { file_fd_ = FileFd::from_native_fd(NativeFd(Stdin().get_native_fd().raw())); read_thread_ = td::thread([this] { this->read_loop(); }); } + BufferedStdinImpl(const BufferedStdinImpl &) = delete; + BufferedStdinImpl &operator=(const BufferedStdinImpl &) = delete; + BufferedStdinImpl(BufferedStdinImpl &&) = delete; + BufferedStdinImpl &operator=(BufferedStdinImpl &&) = delete; ~BufferedStdinImpl() { file_fd_.move_as_native_fd().release(); } @@ -108,6 +112,10 @@ class BufferedStdinImpl { file_fd_ = FileFd::from_native_fd(NativeFd(Stdin().get_native_fd().raw())); file_fd_.get_native_fd().set_is_blocking(false); } + BufferedStdinImpl(const BufferedStdinImpl &) = delete; + BufferedStdinImpl &operator=(const BufferedStdinImpl &) = delete; + BufferedStdinImpl(BufferedStdinImpl &&) = delete; + BufferedStdinImpl &operator=(BufferedStdinImpl &&) = delete; ~BufferedStdinImpl() { file_fd_.move_as_native_fd().release(); } @@ -149,6 +157,7 @@ void BufferedStdinImplDeleter::operator()(BufferedStdinImpl *impl) { } } // namespace detail #endif + BufferedStdin::BufferedStdin() : impl_(std::make_unique().release()) { } BufferedStdin::BufferedStdin(BufferedStdin &&) = default; diff --git a/tdutils/td/utils/port/StdStreams.h b/tdutils/td/utils/port/StdStreams.h index e22dbc51..5868d151 100644 --- a/tdutils/td/utils/port/StdStreams.h +++ b/tdutils/td/utils/port/StdStreams.h @@ -6,9 +6,10 @@ // #pragma once +#include "td/utils/buffer.h" +#include "td/utils/port/detail/PollableFd.h" #include "td/utils/port/FileFd.h" #include "td/utils/port/thread.h" -#include "td/utils/buffer.h" namespace td {