Rewrite of keyword matching code. This fixes #20

Uses new iterator based tagged string functions.
This commit is contained in:
Twan van Laarhoven
2020-05-17 20:37:53 +02:00
parent 0b653938cc
commit b3ddb295fc
8 changed files with 528 additions and 267 deletions
+3 -2
View File
@@ -403,7 +403,7 @@ SCRIPT_FUNCTION(sort_text) {
/// Replace the contents of a specific tag with the value of a script function
String replace_tag_contents(String input, const String& tag, const ScriptValueP& contents, Context& ctx) {
assert_tagged(input, false);
assert_tagged(input);
String ret;
size_t start = 0, pos = input.find(tag);
while (pos != String::npos) {
@@ -674,7 +674,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) {
SCRIPT_OPTIONAL_PARAM_C_(CardP, card);
try {
KeywordUsageStatistics* stat = card ? &card->keyword_usage : nullptr;
SCRIPT_RETURN(db.expand(input, match_condition, default_expand, combine, ctx, stat));
Value* stat_key = value_being_updated();
SCRIPT_RETURN(db.expand(input, KeywordExpandOptions{match_condition, default_expand, combine, ctx, stat, stat_key}));
} catch (const Error& e) {
throw ScriptError(_ERROR_2_("in function", e.what(), _("expand_keywords")));
}