Minor fixes.

GitOrigin-RevId: 793bc74ee1c82b5a86e044be65e4be0e5ce00336
This commit is contained in:
levlam 2018-09-10 21:45:34 +03:00
parent f4c85df878
commit a165b42575
3 changed files with 13 additions and 2 deletions

View File

@ -47,6 +47,7 @@
#include <array>
#include <atomic>
#include <clocale>
#include <cstdio>
#include <cstdlib>
#include <cstring> // for strcmp
#include <ctime>
@ -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);

View File

@ -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<detail::BufferedStdinImpl>().release()) {
}
BufferedStdin::BufferedStdin(BufferedStdin &&) = default;

View File

@ -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 {