don't add invalid keywords (empty match) to database.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@277 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-04-21 17:46:47 +00:00
parent 91ddd35064
commit 454605bb5d
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -170,7 +170,11 @@ void Keyword::prepare(const vector<KeywordParamP>& param_types, bool force) {
}
}
regex += _(")");
if (!matchRe.Compile(regex, wxRE_ADVANCED)) {
if (matchRe.Compile(regex, wxRE_ADVANCED)) {
// not valid if it matches "", that would make MSE hang
valid = !matchRe.Matches(_(""));
} else {
valid = false;
throw InternalError(_("Error creating match regex"));
}
}
@@ -254,7 +258,7 @@ void KeywordDatabase::add(const vector<KeywordP>& kws) {
}
void KeywordDatabase::add(const Keyword& kw) {
if (kw.match.empty()) return; // can't handle empty keywords
if (kw.match.empty() || !kw.valid) return; // can't handle empty keywords
if (!root) {
root = new KeywordTrie;
root->on_any_star = root;
+1 -1
View File
@@ -65,7 +65,7 @@ class KeywordMode {
/// A keyword for a set or a game
class Keyword {
public:
Keyword() : fixed(false) {}
Keyword() : fixed(false), valid(false) {}
String keyword; ///< The keyword, only for human use
String rules; ///< Rules/explanation