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 /hyprctl | |
| parent | dab50b3ef3a1bad7f68320538223b6b41d1c6012 (diff) | |
core: Move regex from stdlib to re2 (#8736)
Moves the regex handling from stdlib to re2
Diffstat (limited to 'hyprctl')
| -rw-r--r-- | hyprctl/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | hyprctl/main.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/hyprctl/CMakeLists.txt b/hyprctl/CMakeLists.txt index aaffe411..db5ef615 100644 --- a/hyprctl/CMakeLists.txt +++ b/hyprctl/CMakeLists.txt @@ -5,7 +5,7 @@ project( DESCRIPTION "Control utility for Hyprland" ) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET hyprutils>=0.1.1) +pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 re2) add_executable(hyprctl "main.cpp") diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 55c3cc7e..676c8b98 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -1,3 +1,5 @@ +#include <re2/re2.h> + #include <cctype> #include <netdb.h> #include <netinet/in.h> @@ -23,7 +25,6 @@ #include <vector> #include <filesystem> #include <cstdarg> -#include <regex> #include <sys/socket.h> #include <hyprutils/string/String.hpp> #include <cstring> @@ -281,11 +282,10 @@ int requestHyprpaper(std::string arg) { } void batchRequest(std::string arg, bool json) { - std::string commands = arg.substr(arg.find_first_of(" ") + 1); + std::string commands = arg.substr(arg.find_first_of(' ') + 1); - if (json) { - commands = "j/" + std::regex_replace(commands, std::regex(";\\s*"), ";j/"); - } + if (json) + RE2::GlobalReplace(&commands, ";\\s*", ";j/"); std::string rq = "[[BATCH]]" + commands; request(rq); |
