Skip to content

Commit

Permalink
fix: qualify std::exp after including <cmath>
Browse files Browse the repository at this point in the history
As noted in #462, including <cmath> only guarantees that std::exp is
declared, so calling exp(double) unqualified is not portable.

Squashed commit with a style change to the original PR:

commit 8b9d48c0340f3fb82de59a6f7ec71ddfd86a602f
Author: Chen Gong <chen.sst@gmail.com>
Date:   Sun Jan 16 00:49:47 2022 +0800

commit df4fe3e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 10 10:18:38 2021 +0100

Closes #476
  • Loading branch information
lotem committed Jan 15, 2022
1 parent 6149f08 commit bc589fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/rime/gear/script_translator.cc
Expand Up @@ -488,9 +488,9 @@ void ScriptTranslation::PrepareCandidate() {
start_,
start_ + user_phrase_code_length,
entry);
cand->set_quality(exp(entry->weight) +
translator_->initial_quality() +
(IsNormalSpelling() ? 0.5 : -0.5));
cand->set_quality(std::exp(entry->weight) +
translator_->initial_quality() +
(IsNormalSpelling() ? 0.5 : -0.5));
}
else if (phrase_code_length > 0) {
DictEntryIterator& iter = phrase_iter_->second;
Expand All @@ -502,9 +502,9 @@ void ScriptTranslation::PrepareCandidate() {
start_,
start_ + phrase_code_length,
entry);
cand->set_quality(exp(entry->weight) +
translator_->initial_quality() +
(IsNormalSpelling() ? 0 : -1));
cand->set_quality(std::exp(entry->weight) +
translator_->initial_quality() +
(IsNormalSpelling() ? 0 : -1));
}
candidate_ = cand;
}
Expand Down
8 changes: 4 additions & 4 deletions src/rime/gear/table_translator.cc
Expand Up @@ -81,10 +81,10 @@ an<Candidate> TableTranslation::Peek() {
if (phrase) {
phrase->set_comment(comment);
phrase->set_preedit(preedit_);
phrase->set_quality(exp(e->weight) +
options_->initial_quality() +
(incomplete ? -1 : 0) +
(is_user_phrase ? 0.5 : 0));
phrase->set_quality(std::exp(e->weight) +
options_->initial_quality() +
(incomplete ? -1 : 0) +
(is_user_phrase ? 0.5 : 0));
}
return phrase;
}
Expand Down

0 comments on commit bc589fd

Please sign in to comment.