mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move regex matching code to zeek namespaces
This commit is contained in:
parent
382812298d
commit
c7dc7fc955
26 changed files with 266 additions and 172 deletions
110
src/RE.cc
110
src/RE.cc
|
@ -12,16 +12,22 @@
|
|||
#include "Reporter.h"
|
||||
#include "ZeekString.h"
|
||||
|
||||
CCL* curr_ccl = nullptr;
|
||||
|
||||
Specific_RE_Matcher* rem;
|
||||
NFA_Machine* nfa = nullptr;
|
||||
int case_insensitive = 0;
|
||||
zeek::detail::CCL* zeek::detail::curr_ccl = nullptr;
|
||||
zeek::detail::CCL*& curr_ccl = zeek::detail::curr_ccl;
|
||||
zeek::detail::Specific_RE_Matcher* zeek::detail::rem = nullptr;
|
||||
zeek::detail::Specific_RE_Matcher*& rem = zeek::detail::rem;
|
||||
zeek::detail::NFA_Machine* zeek::detail::nfa = nullptr;
|
||||
zeek::detail::NFA_Machine*& nfa = zeek::detail::nfa;
|
||||
int zeek::detail::case_insensitive = 0;
|
||||
int& case_insensitive = zeek::detail::case_insensitive;
|
||||
|
||||
extern int RE_parse(void);
|
||||
extern void RE_set_input(const char* str);
|
||||
extern void RE_done_with_scan();
|
||||
|
||||
namespace zeek {
|
||||
namespace detail {
|
||||
|
||||
Specific_RE_Matcher::Specific_RE_Matcher(match_type arg_mt, int arg_multiline)
|
||||
: equiv_class(NUM_SYM)
|
||||
{
|
||||
|
@ -440,51 +446,6 @@ unsigned int Specific_RE_Matcher::MemoryAllocation() const
|
|||
+ accepted->size() * padded_sizeof(AcceptingSet::key_type);
|
||||
}
|
||||
|
||||
RE_Matcher::RE_Matcher()
|
||||
{
|
||||
re_anywhere = new Specific_RE_Matcher(MATCH_ANYWHERE);
|
||||
re_exact = new Specific_RE_Matcher(MATCH_EXACTLY);
|
||||
}
|
||||
|
||||
RE_Matcher::RE_Matcher(const char* pat)
|
||||
{
|
||||
re_anywhere = new Specific_RE_Matcher(MATCH_ANYWHERE);
|
||||
re_exact = new Specific_RE_Matcher(MATCH_EXACTLY);
|
||||
|
||||
AddPat(pat);
|
||||
}
|
||||
|
||||
RE_Matcher::RE_Matcher(const char* exact_pat, const char* anywhere_pat)
|
||||
{
|
||||
re_anywhere = new Specific_RE_Matcher(MATCH_ANYWHERE);
|
||||
re_anywhere->SetPat(anywhere_pat);
|
||||
re_exact = new Specific_RE_Matcher(MATCH_EXACTLY);
|
||||
re_exact->SetPat(exact_pat);
|
||||
}
|
||||
|
||||
RE_Matcher::~RE_Matcher()
|
||||
{
|
||||
delete re_anywhere;
|
||||
delete re_exact;
|
||||
}
|
||||
|
||||
void RE_Matcher::AddPat(const char* new_pat)
|
||||
{
|
||||
re_anywhere->AddPat(new_pat);
|
||||
re_exact->AddPat(new_pat);
|
||||
}
|
||||
|
||||
void RE_Matcher::MakeCaseInsensitive()
|
||||
{
|
||||
re_anywhere->MakeCaseInsensitive();
|
||||
re_exact->MakeCaseInsensitive();
|
||||
}
|
||||
|
||||
bool RE_Matcher::Compile(bool lazy)
|
||||
{
|
||||
return re_anywhere->Compile(lazy) && re_exact->Compile(lazy);
|
||||
}
|
||||
|
||||
static RE_Matcher* matcher_merge(const RE_Matcher* re1, const RE_Matcher* re2,
|
||||
const char* merge_op)
|
||||
{
|
||||
|
@ -513,3 +474,52 @@ RE_Matcher* RE_Matcher_disjunction(const RE_Matcher* re1, const RE_Matcher* re2)
|
|||
{
|
||||
return matcher_merge(re1, re2, "|");
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
RE_Matcher::RE_Matcher()
|
||||
{
|
||||
re_anywhere = new detail::Specific_RE_Matcher(zeek::detail::MATCH_ANYWHERE);
|
||||
re_exact = new detail::Specific_RE_Matcher(zeek::detail::MATCH_EXACTLY);
|
||||
}
|
||||
|
||||
RE_Matcher::RE_Matcher(const char* pat)
|
||||
{
|
||||
re_anywhere = new detail::Specific_RE_Matcher(zeek::detail::MATCH_ANYWHERE);
|
||||
re_exact = new detail::Specific_RE_Matcher(zeek::detail::MATCH_EXACTLY);
|
||||
|
||||
AddPat(pat);
|
||||
}
|
||||
|
||||
RE_Matcher::RE_Matcher(const char* exact_pat, const char* anywhere_pat)
|
||||
{
|
||||
re_anywhere = new detail::Specific_RE_Matcher(zeek::detail::MATCH_ANYWHERE);
|
||||
re_anywhere->SetPat(anywhere_pat);
|
||||
re_exact = new detail::Specific_RE_Matcher(zeek::detail::MATCH_EXACTLY);
|
||||
re_exact->SetPat(exact_pat);
|
||||
}
|
||||
|
||||
RE_Matcher::~RE_Matcher()
|
||||
{
|
||||
delete re_anywhere;
|
||||
delete re_exact;
|
||||
}
|
||||
|
||||
void RE_Matcher::AddPat(const char* new_pat)
|
||||
{
|
||||
re_anywhere->AddPat(new_pat);
|
||||
re_exact->AddPat(new_pat);
|
||||
}
|
||||
|
||||
void RE_Matcher::MakeCaseInsensitive()
|
||||
{
|
||||
re_anywhere->MakeCaseInsensitive();
|
||||
re_exact->MakeCaseInsensitive();
|
||||
}
|
||||
|
||||
bool RE_Matcher::Compile(bool lazy)
|
||||
{
|
||||
return re_anywhere->Compile(lazy) && re_exact->Compile(lazy);
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue