Skip to content

Commit b7c3918

Browse files
authored
Merge branch 'master' into config
2 parents fa9f21f + 92a94cd commit b7c3918

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ test: release
4848
(cd build/test; ./rime_test)
4949

5050
test-debug: release
51-
(cd build/test; ./rime_test)
51+
(cd debug-build/test; ./rime_test)
5252

src/rime/gear/charset_filter.cc

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ bool is_extended_cjk(uint32_t ch)
2323
(ch >= 0x2A700 && ch <= 0x2B73F) || // CJK Unified Ideographs Extension C
2424
(ch >= 0x2B740 && ch <= 0x2B81F) || // CJK Unified Ideographs Extension D
2525
(ch >= 0x2B820 && ch <= 0x2CEAF) || // CJK Unified Ideographs Extension E
26+
(ch >= 0x2CEB0 && ch <= 0x2EBEF) || // CJK Unified Ideographs Extension F
2627
(ch >= 0x2F800 && ch <= 0x2FA1F)) // CJK Compatibility Ideographs Supplement
2728
return true;
2829

src/rime/gear/simplifier.cc

+12-4
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ class Opencc {
3434
Opencc(const string& config_path) {
3535
LOG(INFO) << "initilizing opencc: " << config_path;
3636
opencc::Config config;
37-
converter_ = config.NewFromFile(config_path);
38-
const list<opencc::ConversionPtr> conversions =
39-
converter_->GetConversionChain()->GetConversions();
40-
dict_ = conversions.front()->GetDict();
37+
try {
38+
converter_ = config.NewFromFile(config_path);
39+
const list<opencc::ConversionPtr> conversions =
40+
converter_->GetConversionChain()->GetConversions();
41+
dict_ = conversions.front()->GetDict();
42+
}
43+
catch (...) {
44+
LOG(ERROR) << "opencc config not found: " << config_path;
45+
}
4146
}
4247

4348
bool ConvertWord(const string& text,
4449
vector<string>* forms) {
50+
if (dict_ == nullptr) return false;
4551
opencc::Optional<const opencc::DictEntry*> item = dict_->Match(text);
4652
if (item.IsNull()) {
4753
// Match not found
@@ -57,6 +63,7 @@ class Opencc {
5763

5864
bool RandomConvertText(const string& text,
5965
string* simplified) {
66+
if (dict_ == nullptr) return false;
6067
const char *phrase = text.c_str();
6168
std::ostringstream buffer;
6269
for (const char* pstr = phrase; *pstr != '\0';) {
@@ -78,6 +85,7 @@ class Opencc {
7885

7986
bool ConvertText(const string& text,
8087
string* simplified) {
88+
if (converter_ == nullptr) return false;
8189
*simplified = converter_->Convert(text);
8290
return *simplified != text;
8391
}

0 commit comments

Comments
 (0)