From ae800133b4db40c4528179edd266eacfa606e711 Mon Sep 17 00:00:00 2001 From: Carbo Kuo Date: Thu, 25 Jul 2024 23:21:37 -0400 Subject: [PATCH] Fix VS build warnings. --- src/BinaryDict.cpp | 2 +- src/Config.cpp | 4 ++-- src/PhraseExtract.cpp | 2 +- src/PhraseExtractTest.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BinaryDict.cpp b/src/BinaryDict.cpp index c57756615..fcfa01099 100644 --- a/src/BinaryDict.cpp +++ b/src/BinaryDict.cpp @@ -67,7 +67,7 @@ void BinaryDict::SerializeToFile(FILE* fp) const { } BinaryDictPtr BinaryDict::NewFromFile(FILE* fp) { - size_t offsetBound, savedOffset; + long offsetBound, savedOffset; savedOffset = ftell(fp); fseek(fp, 0L, SEEK_END); offsetBound = ftell(fp) - savedOffset; diff --git a/src/Config.cpp b/src/Config.cpp index aaee40992..31f67a868 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -172,7 +172,7 @@ class ConfigInternal { } std::string FindConfigFile(std::string fileName, - const std::vector& paths) { + const std::vector& configPaths) { std::ifstream ifs; // Working directory @@ -194,7 +194,7 @@ class ConfigInternal { } } - for (const std::string& dirPath : paths) { + for (const std::string& dirPath : configPaths) { std::string path = dirPath + '/' + fileName; ifs.open(UTF8Util::GetPlatformString(path).c_str()); if (ifs.is_open()) { diff --git a/src/PhraseExtract.cpp b/src/PhraseExtract.cpp index a9a62466b..69c21bbaa 100644 --- a/src/PhraseExtract.cpp +++ b/src/PhraseExtract.cpp @@ -101,7 +101,7 @@ class PhraseExtract::DictType { void BuildTrie() { std::unordered_map key_item_id_map; marisa::Keyset keyset; - for (size_t i = 0; i < items.size(); i++) { + for (int i = 0; i < items.size(); i++) { const auto& key = items[i].first; key_item_id_map[key.ToString()] = i; keyset.push_back(key.CString(), key.ByteLength()); diff --git a/src/PhraseExtractTest.cpp b/src/PhraseExtractTest.cpp index decefac5f..7312424c4 100644 --- a/src/PhraseExtractTest.cpp +++ b/src/PhraseExtractTest.cpp @@ -158,8 +158,8 @@ TEST_F(PhraseExtractTest, SelectWords) { phraseExtract.SetWordMaxLength(3); phraseExtract.SetFullText(siShi); phraseExtract.SetPostCalculationFilter( - [](const PhraseExtract& phraseExtract, const UTF8StringSlice8Bit& word) { - return phraseExtract.Frequency(word) == 1; + [](const PhraseExtract& p, const UTF8StringSlice8Bit& word) { + return p.Frequency(word) == 1; }); phraseExtract.SelectWords(); EXPECT_EQ(std::vector({"十", "四", "是", "四十", "十四",