Dont use a regex to match face spec for regex highlighter

This commit is contained in:
Maxime Coste 2015-05-03 18:22:49 +01:00
parent 78eb437b90
commit 7f0588c02c

View File

@ -254,17 +254,16 @@ public:
try try
{ {
static Regex face_spec_ex(R"((\d+):(.*))");
FacesSpec faces; FacesSpec faces;
for (auto it = params.begin() + 1; it != params.end(); ++it) for (auto it = params.begin() + 1; it != params.end(); ++it)
{ {
MatchResults<String::const_iterator> res; auto colon = find(*it, ':');
if (not regex_match(it->begin(), it->end(), res, face_spec_ex)) if (colon == it->end())
throw runtime_error("wrong face spec: '" + *it + throw runtime_error("wrong face spec: '" + *it +
"' expected <capture>:<facespec>"); "' expected <capture>:<facespec>");
get_face({res[2].first, res[2].second}); // throw if wrong face spec get_face({colon+1, it->end()}); // throw if wrong face spec
int capture = str_to_int({res[1].first, res[1].second}); int capture = str_to_int({it->begin(), colon});
faces.emplace_back(capture, String{res[2].first, res[2].second}); faces.emplace_back(capture, String{colon+1, it->end()});
} }
String id = "hlregex'" + params[0] + "'"; String id = "hlregex'" + params[0] + "'";