Commit b0534242 authored by twanvl's avatar twanvl

Moved part of keyword matching into a separate function; it was way too long

parent c4a752a3
This diff is collapsed.
...@@ -152,12 +152,23 @@ class KeywordDatabase { ...@@ -152,12 +152,23 @@ class KeywordDatabase {
/// Expand/update all keywords in the given string. /// Expand/update all keywords in the given string.
/** @param expand_default script function indicating whether reminder text should be shown by default /** @param expand_default script function indicating whether reminder text should be shown by default
* @param combine_script script function to combine keyword and reminder text in some way * @param combine_script script function to combine keyword and reminder text in some way
* @param case_sensitive case sensitive matching of keywords?
* @param ctx context for evaluation of scripts * @param ctx context for evaluation of scripts
*/ */
String expand(const String& text, const ScriptValueP& expand_default, const ScriptValueP& combine_script, Context& ctx) const; String expand(const String& text, const ScriptValueP& expand_default, const ScriptValueP& combine_script, bool case_sensitive, Context& ctx) const;
private: private:
KeywordTrie* root; ///< Data structure for finding keywords KeywordTrie* root; ///< Data structure for finding keywords
/// (try to) expand a single keyword
/** If the keyword matches:
* - add the result to out
* - advance the tagged and untagged string by dropping a part from the front
* - return true
*/
bool tryExpand(const Keyword& kw, size_t pos, String& tagged, String& untagged, String& out, char expand_type,
const ScriptValueP& expand_default, const ScriptValueP& combine_script, bool case_sensitive, Context& ctx,
KeywordUsageStatistics* stat, Value* stat_key) const;
}; };
// ----------------------------------------------------------------------------- : Processing parameters // ----------------------------------------------------------------------------- : Processing parameters
......
...@@ -553,7 +553,7 @@ SCRIPT_RULE_2_N_DEP(expand_keywords, ScriptValueP, _("default expand"), default_ ...@@ -553,7 +553,7 @@ SCRIPT_RULE_2_N_DEP(expand_keywords, ScriptValueP, _("default expand"), default_
SCRIPT_OPTIONAL_PARAM_C_(CardP, card); SCRIPT_OPTIONAL_PARAM_C_(CardP, card);
WITH_DYNAMIC_ARG(keyword_usage_statistics, card ? &card->keyword_usage : nullptr); WITH_DYNAMIC_ARG(keyword_usage_statistics, card ? &card->keyword_usage : nullptr);
try { try {
SCRIPT_RETURN(db.expand(input, default_expand, combine, ctx)); SCRIPT_RETURN(db.expand(input, default_expand, combine, true, ctx));
} catch (const Error& e) { } catch (const Error& e) {
throw ScriptError(_ERROR_2_("in function", e.what(), _("expand_keywords"))); throw ScriptError(_ERROR_2_("in function", e.what(), _("expand_keywords")));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment