From 7f0588c02cac7373490643aebec8083354995a53 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 3 May 2015 18:22:49 +0100 Subject: [PATCH] Dont use a regex to match face spec for regex highlighter --- src/highlighters.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index e65401a9..4323f674 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -254,17 +254,16 @@ public: try { - static Regex face_spec_ex(R"((\d+):(.*))"); FacesSpec faces; for (auto it = params.begin() + 1; it != params.end(); ++it) { - MatchResults res; - if (not regex_match(it->begin(), it->end(), res, face_spec_ex)) + auto colon = find(*it, ':'); + if (colon == it->end()) throw runtime_error("wrong face spec: '" + *it + "' expected :"); - get_face({res[2].first, res[2].second}); // throw if wrong face spec - int capture = str_to_int({res[1].first, res[1].second}); - faces.emplace_back(capture, String{res[2].first, res[2].second}); + get_face({colon+1, it->end()}); // throw if wrong face spec + int capture = str_to_int({it->begin(), colon}); + faces.emplace_back(capture, String{colon+1, it->end()}); } String id = "hlregex'" + params[0] + "'";