diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-12-16 19:21:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-16 19:21:44 +0100 |
| commit | e06b520427a30f1c86562ad7cc3794bf03b40188 (patch) | |
| tree | 54cbdf6f61c22d6abc4ef16fe6a5dabdf2542b1a /src/Compositor.cpp | |
| parent | dab50b3ef3a1bad7f68320538223b6b41d1c6012 (diff) | |
core: Move regex from stdlib to re2 (#8736)
Moves the regex handling from stdlib to re2
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 4276a74e..ecf251f3 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1,3 +1,5 @@ +#include <re2/re2.h> + #include "Compositor.hpp" #include "debug/Log.hpp" #include "helpers/Splashes.hpp" @@ -2392,19 +2394,19 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) { eFocusWindowMode mode = MODE_CLASS_REGEX; - std::regex regexCheck(regexp_); + std::string regexCheck; std::string matchCheck; if (regexp.starts_with("class:")) { - regexCheck = std::regex(regexp.substr(6)); + regexCheck = regexp.substr(6); } else if (regexp.starts_with("initialclass:")) { mode = MODE_INITIAL_CLASS_REGEX; - regexCheck = std::regex(regexp.substr(13)); + regexCheck = regexp.substr(13); } else if (regexp.starts_with("title:")) { mode = MODE_TITLE_REGEX; - regexCheck = std::regex(regexp.substr(6)); + regexCheck = regexp.substr(6); } else if (regexp.starts_with("initialtitle:")) { mode = MODE_INITIAL_TITLE_REGEX; - regexCheck = std::regex(regexp.substr(13)); + regexCheck = regexp.substr(13); } else if (regexp.starts_with("address:")) { mode = MODE_ADDRESS; matchCheck = regexp.substr(8); @@ -2420,25 +2422,25 @@ PHLWINDOW CCompositor::getWindowByRegex(const std::string& regexp_) { switch (mode) { case MODE_CLASS_REGEX: { const auto windowClass = w->m_szClass; - if (!std::regex_search(windowClass, regexCheck)) + if (!RE2::FullMatch(windowClass, regexCheck)) continue; break; } case MODE_INITIAL_CLASS_REGEX: { const auto initialWindowClass = w->m_szInitialClass; - if (!std::regex_search(initialWindowClass, regexCheck)) + if (!RE2::FullMatch(initialWindowClass, regexCheck)) continue; break; } case MODE_TITLE_REGEX: { const auto windowTitle = w->m_szTitle; - if (!std::regex_search(windowTitle, regexCheck)) + if (!RE2::FullMatch(windowTitle, regexCheck)) continue; break; } case MODE_INITIAL_TITLE_REGEX: { const auto initialWindowTitle = w->m_szInitialTitle; - if (!std::regex_search(initialWindowTitle, regexCheck)) + if (!RE2::FullMatch(initialWindowTitle, regexCheck)) continue; break; } |
