Skip to content

Commit ed44854

Browse files
committed
Replace all CRLF to LF.
1 parent b35de1c commit ed44854

28 files changed

+325
-402
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
insert_final_newline = false
13+
trim_trailing_whitespace = false

3rdparty/imgui/node-editor/crude_json.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Crude implementation of JSON value object and parser.
1+
// Crude implementation of JSON value object and parser.
22
//
33
// VERSION 0.1
44
//

3rdparty/imgui/node-editor/imgui_canvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Canvas widget - view over infinite virtual space.
1+
// Canvas widget - view over infinite virtual space.
22
//
33
// Canvas allows you to draw your widgets anywhere over infinite space and provide
44
// view over it with support for panning and scaling.

3rdparty/ktx/gl_format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
================================================================================================
33
44
Description : OpenGL formats/types and properties.

3rdparty/pinyin/Cache.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#include "Cache.h"
1+
#include "Cache.h"
22
#include <algorithm>
33
#include "PinyinHanzi.h"
44
#include "StringFunction.h"
55

66
using namespace ime::pinyin;
77

8-
//为了兼容多个引擎,全局变量应该对象化
98
std::map<std::string, std::shared_ptr<Query>> g_queryLineCaches;
109
std::map<std::string, std::shared_ptr<Query>> g_combineAssociateLineCaches;
1110
std::map<std::string, std::vector<std::string>> g_SingleCaches;
@@ -16,7 +15,6 @@ std::shared_ptr<Query> QueryLineCache::getQuery(const std::string & validPinyinS
1615
if (iter == g_queryLineCaches.end())
1716
{
1817
std::shared_ptr<Query> p = std::make_shared<Query>();
19-
//搜索size=,pinyin like的条目
2018
p->search(Query::pinyin | Query::cizu | Query::weight, std::count(validPinyinStr.begin(), validPinyinStr.end(), '\'') + 1, Query::Condition::eq,
2119
validPinyinStr, Query::Condition::like, false, false, "", Query::Condition::none, Query::weight);
2220
g_queryLineCaches.insert({ validPinyinStr, p });
@@ -40,7 +38,6 @@ std::shared_ptr<Query> CombineLineCache::getQuery(const std::string & validPinyi
4038
if (iter == g_combineAssociateLineCaches.end())
4139
{
4240
std::shared_ptr<Query> p = std::make_shared<Query>();
43-
//搜索size=,pinyin like的条目
4441
p->search(Query::pinyin | Query::cizu | Query::priority, std::count(validPinyinStr.begin(), validPinyinStr.end(), '\'') + 1, Query::Condition::eq,
4542
validPinyinStr, Query::Condition::like, false, false, "", Query::Condition::none, Query::priority);
4643
g_combineAssociateLineCaches.insert({ validPinyinStr, p });

3rdparty/pinyin/Cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
#include <vector>
33
#include "Query.h"
44
#include "Share.h"

3rdparty/pinyin/CandidateStubs.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "CandidateStubs.h"
1+
#include "CandidateStubs.h"
22
#include "Query.h"
33
#include "StringFunction.h"
44
#include "PinyinBase.h"
@@ -11,12 +11,9 @@ void CombineAssociateCandidate::setInput(const std::string &divided, bool enable
1111
{
1212
clear();
1313
m_divided = divided;
14-
//如果只有单个拼音,则没有组合词组
1514
if (m_divided.find("'") == std::string::npos)
1615
return;
1716

18-
//以下获取不可调换顺序
19-
//按顺序搜索获取组合词(成功表示最长长度的pinyin不能搜索到词组;反之搜到了词组,不再获取组合词和联想词)
2017
std::string sFirstPinyins;
2118
std::wstring sFirstCizu;
2219
std::string sSecondPinyin;
@@ -28,18 +25,13 @@ void CombineAssociateCandidate::setInput(const std::string &divided, bool enable
2825
return;
2926
}
3027

31-
//如果最长长度的pinyin不能搜索到词组,获取模糊词组
3228
if (enableAssociateCandidate)
3329
getAssociate(m_divided);
3430

35-
//如果最长长度的pinyin不能搜索到词组,才执行下面
36-
//且第一个拼音是特殊独立的汉字拼音比如“我”,“你”,“他”,“这”等
37-
//sFirstCizu.size()是1的话第二组合词肯定等于第一个组合词了,没必要再获取
3831
bool bGetSecond = false;
3932
if (enableCombineCandidate && bGetFirst && sFirstCizu.size() != 1)
4033
bGetSecond = getSecondCombine(m_divided);
4134

42-
//sCombineCizu2未插入且第二个词为特殊独立的汉字拼音就添加一个组合词
4335
if (enableCombineCandidate && !bGetSecond)
4436
bool bGetThird = getThirdCombine(m_divided, sFirstPinyins, sFirstCizu, sSecondPinyin);
4537
}
@@ -92,7 +84,6 @@ bool CombineAssociateCandidate::getFirstCombine(const std::string &input, std::s
9284
firstCizu = StringFunction::utf8ToUnicode(firstCan.cizu);
9385
}
9486

95-
//如果最长长度的pinyin能搜索到词组,取消组合词
9687
if (sSearch == m_divided && firstCan.size == std::count(input.begin(), input.end(), '\'') + 1)
9788
{
9889
return false;
@@ -131,7 +122,6 @@ bool CombineAssociateCandidate::getFirstCombine(const std::string &input, std::s
131122

132123
void CombineAssociateCandidate::getAssociate(const std::string &input)
133124
{
134-
//模糊搜索,与size无关
135125
Query longestQuery;
136126
longestQuery.search(Query::size | Query::pinyin | Query::cizu | Query::weight, -1, Query::Condition::none, input, Query::Condition::like, true, false, "", Query::Condition::none, Query::weight);
137127
for (int i = 0; i != longestQuery.recordCount(); ++i)
@@ -268,13 +258,12 @@ void QueryCandidate::getCandidate(unsigned int index, unsigned int count, std::v
268258
return;
269259

270260
unsigned int nGetCount = 0;
271-
//计算起始query,并获取该query数据
272261
int nStartQueryIndex = 0;
273262
for (int n = 0; nStartQueryIndex != m_queryLine.queryCount(); ++nStartQueryIndex)
274263
{
275264
std::shared_ptr<Query> query = m_queryLine.at(nStartQueryIndex);
276265
n += query->recordCount();
277-
if ((int)index <= n - 1) //强制转换为int,因为n - 1可能被隐性转为unsgned int,导致比较结果错误
266+
if ((int)index <= n - 1)
278267
{
279268
int beg = index - (n - query->recordCount());
280269
int size = m_queryLine.queryCount() + 1 - nStartQueryIndex;
@@ -290,7 +279,6 @@ void QueryCandidate::getCandidate(unsigned int index, unsigned int count, std::v
290279
}
291280
}
292281

293-
//从nStartQueryIndex的下一个query继续获取数据
294282
for (int i = nStartQueryIndex + 1; i != m_queryLine.queryCount(); ++i)
295283
{
296284
int size = m_queryLine.queryCount() + 1 - i;

3rdparty/pinyin/CandidateStubs.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**********************************************
1+
/**********************************************
22
* PRTCandidateCombineAssociate
33
*
44
* 组合词候选词和联想候选词管理器
@@ -47,8 +47,6 @@ class CombineAssociateCandidate
4747
};
4848

4949
bool getFirstCombine(const std::string &input, std::string &firstPinyins, std::wstring &firstCizu, std::string &secondPinyin);
50-
//获取最长模糊查询结果,比如"zai'suo'you'ren'shi'yi'fei'de'jing'se'li'wo'zui'xi'huan'ni",
51-
//输入"zai'suo'you'ren'shi'"也会搜索"zai'suo'you'ren'shi%"
5250
void getAssociate(const std::string &input);
5351
bool getSecondCombine(const std::string &input);
5452
bool getThirdCombine(const std::string &input, const std::string &firstPinyins, std::wstring &firstCizu, std::string &secondPinyin);
@@ -83,4 +81,4 @@ class SinglePinyinCandidate
8381
std::vector<std::string> m_hanzis;
8482
};
8583

86-
}}
84+
}}

3rdparty/pinyin/Ciku.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
#include "Ciku.h"
1+
#include "Ciku.h"
22
#include "sqlite3.h"
33
#include "CikuManager.h"
4-
#ifdef WIN32
4+
#ifdef WIN32
55
#include <io.h>
66
#else
77
#include <unistd.h>
88
#endif
99

1010
using namespace ime::pinyin;
1111
#define ALIAS_PREFIX "DB_"
12-
//全局只需一个句柄即可
1312
sqlite3 *Ciku::m_sqlHandle = nullptr;
1413

1514
bool Ciku::load(const std::string & path)
1615
{
17-
//需要判断db数据库是否存在,不存在它会自动创建的
1816
if (access(path.data(), 0) != 0)
1917
return false;
2018

21-
//打开数据库(第一次需要初始化全局sqlHandl)
2219
if(sqlHandle() == nullptr)
2320
{
2421
if (sqlite3_open(path.data(), &m_sqlHandle) != SQLITE_OK)
2522
return false;
2623
}
2724

28-
//给数据库起别名
2925
char *pErrorMsg = nullptr;
3026
std::string aliasName = calcNextAliasName();
3127
std::string sCmd = "attach database \"" + path + "\" as \"" + aliasName + "\"";
@@ -66,4 +62,4 @@ std::string Ciku::calcNextAliasName() const
6662
{
6763
int count = CikuManager::getCikus().size();
6864
return ALIAS_PREFIX + std::to_string(count);
69-
}
65+
}

3rdparty/pinyin/Ciku.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**********************************************
1+
/**********************************************
22
* Ciku词库
33
*
44
* 1、使用sqlite3
@@ -22,26 +22,21 @@ class Ciku final
2222
Ciku(const Ciku &other) = delete;
2323
void operator = (const Ciku &other) = delete;
2424

25-
//加载
2625
bool load(const std::string &path);
2726

28-
//获取路径
2927
const std::string &path() const;
3028

31-
//别名
3229
const std::string &alias() const;
3330

34-
//全局sql句柄
3531
static sqlite3 *sqlHandle();
3632
static void freeSqlHandle();
3733

3834
private:
39-
//计算数据库别名
4035
std::string calcNextAliasName() const;
4136

4237
static sqlite3 *m_sqlHandle;
4338
std::string m_path;
4439
std::string m_alias;
4540
};
4641

47-
}}
42+
}}

3rdparty/pinyin/CikuManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "CikuManager.h"
1+
#include "CikuManager.h"
22
#include "Ciku.h"
33
#include "StringFunction.h"
44
#include "PinyinBase.h"

3rdparty/pinyin/CikuManager.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*************************************************
1+
/*************************************************
22
* CikuManager词库管理
33
* 类型分为系统词库,学习词库和用户词库,
44
* 其中系统词库和学习词库在引擎初始化时加载
@@ -19,45 +19,31 @@ class CikuManager final
1919
CikuManager() = delete;
2020
~CikuManager() = delete;
2121

22-
//配置system-db和learn-db
2322
static void configure(const std::string &systemCikuPath, const std::string &learnCikuPath);
2423

25-
//初始化,加载system-db和learn-db
2624
static bool init();
2725
static bool deinit();
2826

29-
//添加一个用户词库
3027
static bool addUserCiku(const std::string &path);
3128

32-
//删除一个用户词库
3329
static bool remoteUserCiku(const std::string &path);
3430

35-
//删除所有的用户词库
3631
static void clearUserCiku();
3732

38-
//获取所有的用户词库路径
3933
static void getAllUserCikuPaths(std::vector<std::string> &cikuPaths);
4034

41-
//获取所有词库
4235
static std::vector<std::shared_ptr<Ciku>> getCikus();
4336

44-
//插入一个词条
45-
//长度、pinyin、cizu、优先级、权重
4637
static bool insertRecord(int size, const std::string &completedPinyinStr, const std::string &cizu, int priority, int weight);
4738

48-
//删除一个词条
49-
//completedPinyinStr:形如 "wo'ai'ni",必须是完整的
50-
//cizu:形如:"我爱你"
5139
static bool deleteRecord(const std::string &completedPinyinStr, const std::string &cizu);
5240

53-
//更新
5441
static bool updateRecord(const std::string &srcCompletedPinyin, const std::string &srcCizu, int newSize, const std::string &newCompletedPinyinStr, const std::string &newCizu, int newPriority, int newWeight);
5542

5643
private:
57-
//所有的词库,前两位为system词库和learn词库
5844
static std::string m_systemCikuPath;
5945
static std::string m_learnCikuPath;
6046
static std::vector<std::shared_ptr<Ciku>> m_cikus;
6147
};
6248

63-
}}
49+
}}

3rdparty/pinyin/Pinyin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "pinyin/Pinyin.h"
1+
#include "pinyin/Pinyin.h"
22
#include "Pinyin_Internal.h"
33
#include <exception>
44
#include <cstdlib>

0 commit comments

Comments
 (0)