diff --git a/src/rime/algo/syllabifier.cc b/src/rime/algo/syllabifier.cc index 3b05af5c0e..ecf838b035 100644 --- a/src/rime/algo/syllabifier.cc +++ b/src/rime/algo/syllabifier.cc @@ -106,8 +106,8 @@ int Syllabifier::BuildSyllableGraph(const string& input, exact_match_syllables.end()) { // Accept normal spellings only. if (props.type != kNormalSpelling) { - accessor.Next(); - continue; + accessor.Next(); + continue; } props.is_correction = true; props.credibility = kCorrectionCredibility; diff --git a/src/rime/common.h b/src/rime/common.h index 9b937b0736..35205f74d1 100644 --- a/src/rime/common.h +++ b/src/rime/common.h @@ -99,11 +99,19 @@ class path : public std::filesystem::path { explicit path(const char* utf8_path) : fs_path(utf8_path) {} #endif - path& operator/=(const path& p) { return *this = fs_path::operator/=(p); } - path& operator/=(const fs_path& p) { return *this = fs_path::operator/=(p); } + path& operator/=(const path& p) { + return *this = fs_path::operator/=(p); + } + path& operator/=(const fs_path& p) { + return *this = fs_path::operator/=(p); + } // convert UTF-8 encoded string to native encoding, then append. - path& operator/=(const std::string& p) { return *this /= path(p); } - path& operator/=(const char* p) { return *this /= path(p); } + path& operator/=(const std::string& p) { + return *this /= path(p); + } + path& operator/=(const char* p) { + return *this /= path(p); + } friend path operator/(const path& lhs, const path& rhs) { return path(lhs) /= rhs; diff --git a/src/rime/dict/dictionary.cc b/src/rime/dict/dictionary.cc index c818207361..08831946c2 100644 --- a/src/rime/dict/dictionary.cc +++ b/src/rime/dict/dictionary.cc @@ -17,7 +17,7 @@ namespace rime { -const double kPredictionThreshold = 4.605170185988092; // log(100) +const double kPredictionThreshold = 4.605170185988092; // log(100) namespace dictionary { @@ -253,7 +253,7 @@ static void lookup_table(Table* table, auto entry = a.entry(); if (!predict.entries || cr + entry->weight > predict.credibility + - predict.entries[predict.cursor].weight) { + predict.entries[predict.cursor].weight) { predict_pos = end_pos; predict = {table, a.code(), entry, cr}; } diff --git a/src/rime/dict/table.cc b/src/rime/dict/table.cc index f4c3710de6..d10109f8a7 100644 --- a/src/rime/dict/table.cc +++ b/src/rime/dict/table.cc @@ -200,15 +200,16 @@ TableAccessor TableQuery::Access(SyllableId syllable_id, return TableAccessor(); } -void TableQuery::AccessAll(vector& accessors, double credibility) { +void TableQuery::AccessAll(vector& accessors, + double credibility) { credibility += credibility_.back(); if (level_ == 0) { if (!lv1_index_) return; for (size_t i = 0; i < lv1_index_->size; i++) { auto node = &lv1_index_->at[i]; - TableAccessor accessor(add_syllable(index_code_, i), - &node->entries, credibility); + TableAccessor accessor(add_syllable(index_code_, i), &node->entries, + credibility); if (!accessor.exhausted()) accessors.push_back(accessor); if (!node->next_level) diff --git a/src/rime/dict/table.h b/src/rime/dict/table.h index 53e946420e..376931b3d5 100644 --- a/src/rime/dict/table.h +++ b/src/rime/dict/table.h @@ -14,21 +14,13 @@ #include #include -#define RIME_TABLE_UNION(U, V, A, a, B, b) \ - struct U { \ - V value; \ - const A& a() const { \ - return *reinterpret_cast(this); \ - } \ - const B& b() const { \ - return *reinterpret_cast(this); \ - } \ - A& a() { \ - return *reinterpret_cast(this); \ - } \ - B& b() { \ - return *reinterpret_cast(this); \ - } \ +#define RIME_TABLE_UNION(U, V, A, a, B, b) \ + struct U { \ + V value; \ + const A& a() const { return *reinterpret_cast(this); } \ + const B& b() const { return *reinterpret_cast(this); } \ + A& a() { return *reinterpret_cast(this); } \ + B& b() { return *reinterpret_cast(this); } \ } namespace rime { diff --git a/src/rime/dict/user_db.cc b/src/rime/dict/user_db.cc index 83b855e3b4..980adec5a6 100644 --- a/src/rime/dict/user_db.cc +++ b/src/rime/dict/user_db.cc @@ -36,7 +36,7 @@ string UserDbValue::Pack() const { std::ostringstream packed; packed << "c=" << commits << " d=" << dee << " t=" << tick; if (elements.size() > 1) { - packed << " e=" << boost::join(elements, "/"); + packed << " e=" << boost::join(elements, "/"); } return packed.str(); } diff --git a/src/rime/gear/script_translator.cc b/src/rime/gear/script_translator.cc index 714dff5578..634ceca04f 100644 --- a/src/rime/gear/script_translator.cc +++ b/src/rime/gear/script_translator.cc @@ -312,9 +312,9 @@ string ScriptSyllabifier::GetPreeditString(const Phrase& cand) const { } string ScriptSyllabifier::GetOriginalSpelling(const Phrase& cand) const { - if (translator_ && - (translator_->always_show_comments() || static_cast( - cand.full_code().size()) <= translator_->spelling_hints())) { + if (translator_ && (translator_->always_show_comments() || + static_cast(cand.full_code().size()) <= + translator_->spelling_hints())) { return translator_->Spell(cand.full_code()); } return string(); @@ -345,9 +345,10 @@ bool ScriptTranslation::Evaluate(Dictionary* dict, UserDictionary* user_dict) { return false; if (phrase_ && !phrase_->empty() && phrase_->begin()->first < 0) { const auto& entry = phrase_->begin()->second.Peek(); - prediction_ = New(translator_->language(), "predicted_phrase", start_, - start_ + syllable_graph.interpreted_length, entry, - -phrase_->begin()->first); + prediction_ = + New(translator_->language(), "predicted_phrase", start_, + start_ + syllable_graph.interpreted_length, entry, + -phrase_->begin()->first); prediction_->set_quality(std::exp(entry->weight) + translator_->initial_quality()); phrase_->erase(phrase_->begin()->first); @@ -361,11 +362,12 @@ bool ScriptTranslation::Evaluate(Dictionary* dict, UserDictionary* user_dict) { // If the first candidate is a correction, make sentense. bool is_first_candidate_a_correction = false; if (enable_correction_) { - CheckEmpty(); - PrepareCandidate(); - if (candidate_) { - is_first_candidate_a_correction = syllabifier_->IsCandidateCorrection(*candidate_); - } + CheckEmpty(); + PrepareCandidate(); + if (candidate_) { + is_first_candidate_a_correction = + syllabifier_->IsCandidateCorrection(*candidate_); + } } // make sentences when there is no exact-matching phrase candidate @@ -480,7 +482,8 @@ bool ScriptTranslation::PreferUserPhrase() { return user_phrase_code_length > 0 && user_phrase_code_length >= phrase_code_length && - (user_phrase_code_length > phrase_code_length || user_phrase_weight >= phrase_weight); + (user_phrase_code_length > phrase_code_length || + user_phrase_weight >= phrase_weight); } void ScriptTranslation::PrepareCandidate() { diff --git a/src/rime/lever/deployment_tasks.h b/src/rime/lever/deployment_tasks.h index b3a657f46e..745171216b 100644 --- a/src/rime/lever/deployment_tasks.h +++ b/src/rime/lever/deployment_tasks.h @@ -49,7 +49,8 @@ class RIME_API WorkspaceUpdate : public DeploymentTask { // update a specific schema, build corresponding dictionary class RIME_API SchemaUpdate : public DeploymentTask { public: - explicit SchemaUpdate(const path& source_path, const bool& build_dictionary = true) + explicit SchemaUpdate(const path& source_path, + const bool& build_dictionary = true) : source_path_(source_path), build_dictionary_(build_dictionary) {} SchemaUpdate(TaskInitializer arg); bool Run(Deployer* deployer); diff --git a/src/rime/translation.cc b/src/rime/translation.cc index f023825462..2441df45c2 100644 --- a/src/rime/translation.cc +++ b/src/rime/translation.cc @@ -231,7 +231,8 @@ bool DistinctTranslation::Next() { continue; } if (cand->text() == phrase->text()) { - comment += (comment.empty() || cand->comment().empty() ? "" : "; ") + cand->comment(); + comment += (comment.empty() || cand->comment().empty() ? "" : "; ") + + cand->comment(); translation_->Next(); candidate_set_.insert(pair); } else { @@ -246,7 +247,8 @@ bool DistinctTranslation::Next() { return true; } -bool DistinctTranslation::AlreadyHas(const pair& candidate) const { +bool DistinctTranslation::AlreadyHas( + const pair& candidate) const { return candidate_set_.find(candidate) != candidate_set_.end(); } diff --git a/src/rime/translation.h b/src/rime/translation.h index 454eb2740e..cb96208572 100644 --- a/src/rime/translation.h +++ b/src/rime/translation.h @@ -120,7 +120,8 @@ inline an Cached(Args&&... args) { class DistinctTranslation : public Translation { public: - DistinctTranslation(an translation, const bool combine_candidates); + DistinctTranslation(an translation, + const bool combine_candidates); virtual bool Next(); virtual an Peek(); @@ -129,7 +130,7 @@ class DistinctTranslation : public Translation { bool AlreadyHas(const pair& candidate) const; const bool combine_candidates_; - set > candidate_set_; + set> candidate_set_; an translation_; an cache_; }; diff --git a/src/rime_api.cc b/src/rime_api.cc index 554b44c20b..2f75e7e3ec 100644 --- a/src/rime_api.cc +++ b/src/rime_api.cc @@ -115,7 +115,7 @@ RIME_API Bool RimeStartMaintenance(Bool full_check) { RIME_API Bool RimeStartQuick() { LoadModules(kDeployerModules); - Deployer &deployer(Service::instance().deployer()); + Deployer& deployer(Service::instance().deployer()); deployer.RunTask("clean_old_log_files"); if (!deployer.RunTask("installation_update")) { return False; diff --git a/src/rime_api.h b/src/rime_api.h index 765ddbb0ae..a44f7b53ce 100644 --- a/src/rime_api.h +++ b/src/rime_api.h @@ -294,7 +294,7 @@ RIME_API Bool RimeCandidateListBegin(RimeSessionId session_id, RimeCandidateListIterator* iterator); RIME_API Bool RimeConfigListAppendString(RimeConfig* config, const char* key, - const char* value); + const char* value); RIME_API Bool RimeCandidateListNext(RimeCandidateListIterator* iterator); RIME_API void RimeCandidateListEnd(RimeCandidateListIterator* iterator); RIME_API Bool RimeCandidateListFromIndex(RimeSessionId session_id, diff --git a/tools/rime_api_console.cc b/tools/rime_api_console.cc index 7172b35684..76a8ef39b6 100644 --- a/tools/rime_api_console.cc +++ b/tools/rime_api_console.cc @@ -12,18 +12,13 @@ #include "codepage.h" const std::unordered_map char_replacements = { - {'\0', "<\\0>"}, - {'\a', "<\\a>"}, - {'\b', "<\\b>"}, - {'\t', "<\\t>"}, - {'\n', "<\\n>"}, - {'\v', "<\\v>"}, - {'\f', "<\\f>"}, - {'\r', "<\\r>"}, + {'\0', "<\\0>"}, {'\a', "<\\a>"}, {'\b', "<\\b>"}, {'\t', "<\\t>"}, + {'\n', "<\\n>"}, {'\v', "<\\v>"}, {'\f', "<\\f>"}, {'\r', "<\\r>"}, }; void print_comment(const char* str) { - if (!str) return; + if (!str) + return; for (size_t i = 0; i < strlen(str); ++i) { auto it = char_replacements.find(str[i]); if (it == char_replacements.end()) {