Cosmetics: coding style

This commit is contained in:
Felipe Zimmerle 2019-01-18 10:48:04 -03:00
parent ad28de4f14
commit df3c3f62b7
2 changed files with 12 additions and 10 deletions

View File

@ -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;

View File

@ -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