From 06016ac95282538959f9ff3ec732bca1e7f4448c Mon Sep 17 00:00:00 2001 From: twanvl Date: Sat, 31 May 2008 22:48:39 +0000 Subject: [PATCH] fixed regex escaping bug, keywords with params are now no longer recognized if followed by an opening parenthesis git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@922 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/keyword.cpp | 2 +- src/util/string.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index 3371c40a..f1d01cf2 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -214,7 +214,7 @@ void Keyword::prepare(const vector& param_types, bool force) { } } regex += _("(") + regex_escape(text) + _(")"); - regex = _("\\y") + regex + _("(?=$|[^a-zA-Z0-9])"); // only match whole words + regex = _("\\y") + regex + _("(?=$|[^a-zA-Z0-9\\(])"); // only match whole words if (match_re.Compile(regex, wxRE_ADVANCED)) { // not valid if it matches "", that would make MSE hang valid = !match_re.Matches(_("")); diff --git a/src/util/string.cpp b/src/util/string.cpp index b5d77a86..d845c499 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -422,9 +422,11 @@ String make_non_capturing(const String& re) { String ret; bool escape = false, bracket = false, capture = false; FOR_EACH_CONST(c, re) { - if (capture && c != _('?')) { - // change this capture into a non-capturing "(" by appending "?:" - ret += _("?:"); + if (capture) { + if (c != _('?')) { + // change this capture into a non-capturing "(" by appending "?:" + ret += _("?:"); + } capture = false; } if (escape) { // second char of escape sequence