Skip to content

Commit

Permalink
Remove fcitx::getline usage
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Feb 7, 2025
1 parent 5b7e21e commit 915846d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.6.0)
project(fcitx5-skk VERSION 5.1.6)

set(REQUIRED_FCITX_VERSION 5.1.12)
set(REQUIRED_FCITX_VERSION 5.1.13)
find_package(ECM 1.0.0 REQUIRED)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
option(ENABLE_QT "Enable Qt for GUI configuration" On)
Expand Down
15 changes: 8 additions & 7 deletions src/skk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <istream>
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include <fcitx-config/iniparser.h>
#include <fcitx-utils/capabilityflags.h>
#include <fcitx-utils/fdstreambuf.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/key.h>
#include <fcitx-utils/keysym.h>
Expand Down Expand Up @@ -466,17 +468,16 @@ void SkkEngine::loadDictionary() {
auto file = StandardPath::global().open(StandardPath::Type::PkgData,
"skk/dictionary_list", O_RDONLY);

UniqueFilePtr fp(fdopen(file.fd(), "rb"));
if (!fp) {
if (!file.isValid()) {
return;
}
file.release();

UniqueCPtr<char> buf;
size_t len = 0;
IFDStreamBuf buf(file.fd());
std::istream in(&buf);
std::string line;

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

if (tokens.size() < 3) {
Expand Down

0 comments on commit 915846d

Please sign in to comment.