From df3c3f62b74eb5d8b6e0ac89aeb703335675ca31 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Fri, 18 Jan 2019 10:48:04 -0300 Subject: [PATCH] Cosmetics: coding style --- src/utils/regex.cc | 6 ++---- src/utils/regex.h | 16 ++++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/utils/regex.cc b/src/utils/regex.cc index 13a06617..461f0288 100644 --- a/src/utils/regex.cc +++ b/src/utils/regex.cc @@ -39,8 +39,7 @@ namespace Utils { Regex::Regex(const std::string& pattern_) - : pattern(pattern_.empty() ? ".*" : pattern_) -{ + : pattern(pattern_.empty() ? ".*" : pattern_) { const char *errptr = NULL; int erroffset; @@ -108,8 +107,7 @@ int Regex::search(const std::string& s, SMatch *match) const { if (ret > 0) { *match = SMatch( std::string(s, ovector[ret-1], ovector[ret] - ovector[ret-1]), - 0 - ); + 0); } return ret; diff --git a/src/utils/regex.h b/src/utils/regex.h index da0cca73..147b48f4 100644 --- a/src/utils/regex.h +++ b/src/utils/regex.h @@ -31,13 +31,13 @@ namespace Utils { class SMatch { public: - SMatch() - : m_match(), m_offset(0) - {} + SMatch() : + m_match(), + m_offset(0) { } - SMatch(const std::string &match, size_t offset) - : m_match(match), m_offset(offset) - {} + SMatch(const std::string &match, size_t offset) : + m_match(match), + m_offset(offset) { } const std::string& str() const { return m_match; } size_t offset() const { return m_offset; } @@ -47,6 +47,7 @@ class SMatch { size_t m_offset; }; + class Regex { public: explicit Regex(const std::string& pattern_); @@ -66,14 +67,17 @@ class Regex { pcre_extra *m_pce = NULL; }; + static inline int regex_search(const std::string& s, SMatch *match, const Regex& regex) { return regex.search(s, match); } + static inline int regex_search(const std::string& s, const Regex& regex) { return regex.search(s); } + } // namespace Utils } // namespace modsecurity