mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-24 05:49:49 +01:00
regex: log an error if regex parsing fails
This commit is contained in:
parent
b7a3c45269
commit
76a899627e
1 changed files with 5 additions and 0 deletions
|
@ -1,11 +1,16 @@
|
||||||
#include "Rule.hpp"
|
#include "Rule.hpp"
|
||||||
#include <re2/re2.h>
|
#include <re2/re2.h>
|
||||||
|
#include "../debug/Log.hpp"
|
||||||
|
|
||||||
CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) {
|
CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) {
|
||||||
const bool NEGATIVE = regex_.starts_with("negative:");
|
const bool NEGATIVE = regex_.starts_with("negative:");
|
||||||
|
|
||||||
negative = NEGATIVE;
|
negative = NEGATIVE;
|
||||||
regex = std::make_unique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
|
regex = std::make_unique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
|
||||||
|
|
||||||
|
// TODO: maybe pop an error?
|
||||||
|
if (!regex->ok())
|
||||||
|
Debug::log(ERR, "RuleRegexContainer: regex {} failed to parse!", regex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRuleRegexContainer::passes(const std::string& str) const {
|
bool CRuleRegexContainer::passes(const std::string& str) const {
|
||||||
|
|
Loading…
Reference in a new issue