Skip to content

Commit 915846d

Browse files
committed
Remove fcitx::getline usage
1 parent 5b7e21e commit 915846d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.6.0)
22
project(fcitx5-skk VERSION 5.1.6)
33

4-
set(REQUIRED_FCITX_VERSION 5.1.12)
4+
set(REQUIRED_FCITX_VERSION 5.1.13)
55
find_package(ECM 1.0.0 REQUIRED)
66
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
77
option(ENABLE_QT "Enable Qt for GUI configuration" On)

src/skk.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
#include <cstdint>
1313
#include <cstdio>
1414
#include <cstring>
15+
#include <istream>
1516
#include <memory>
1617
#include <stdexcept>
1718
#include <string>
1819
#include <utility>
1920
#include <vector>
2021
#include <fcitx-config/iniparser.h>
2122
#include <fcitx-utils/capabilityflags.h>
23+
#include <fcitx-utils/fdstreambuf.h>
2224
#include <fcitx-utils/i18n.h>
2325
#include <fcitx-utils/key.h>
2426
#include <fcitx-utils/keysym.h>
@@ -466,17 +468,16 @@ void SkkEngine::loadDictionary() {
466468
auto file = StandardPath::global().open(StandardPath::Type::PkgData,
467469
"skk/dictionary_list", O_RDONLY);
468470

469-
UniqueFilePtr fp(fdopen(file.fd(), "rb"));
470-
if (!fp) {
471+
if (!file.isValid()) {
471472
return;
472473
}
473-
file.release();
474474

475-
UniqueCPtr<char> buf;
476-
size_t len = 0;
475+
IFDStreamBuf buf(file.fd());
476+
std::istream in(&buf);
477+
std::string line;
477478

478-
while (getline(buf, &len, fp.get()) != -1) {
479-
const auto trimmed = stringutils::trim(buf.get());
479+
while (std::getline(in, line)) {
480+
const auto trimmed = stringutils::trimView(line);
480481
const auto tokens = stringutils::split(trimmed, ",");
481482

482483
if (tokens.size() < 3) {

0 commit comments

Comments
 (0)