mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 02:58:20 +00:00
implemented /re/i for case-insensitive patterns
This commit is contained in:
parent
bd5414d8d5
commit
80b3b82b54
8 changed files with 117 additions and 27 deletions
19
src/RE.cc
19
src/RE.cc
|
@ -102,6 +102,19 @@ void Specific_RE_Matcher::AddPat(const char* new_pat,
|
|||
pattern_text = s;
|
||||
}
|
||||
|
||||
void Specific_RE_Matcher::MakeCaseInsensitive()
|
||||
{
|
||||
const char fmt[] = "(+i %s)";
|
||||
int n = strlen(pattern_text) + strlen(fmt);
|
||||
|
||||
char* s = new char[n + 5 /* slop */];
|
||||
|
||||
safe_snprintf(s, n + 5, fmt, pattern_text);
|
||||
|
||||
delete [] pattern_text;
|
||||
pattern_text = s;
|
||||
}
|
||||
|
||||
int Specific_RE_Matcher::Compile(int lazy)
|
||||
{
|
||||
if ( ! pattern_text )
|
||||
|
@ -444,6 +457,12 @@ void RE_Matcher::AddPat(const char* new_pat)
|
|||
re_exact->AddPat(new_pat);
|
||||
}
|
||||
|
||||
void RE_Matcher::MakeCaseInsensitive()
|
||||
{
|
||||
re_anywhere->MakeCaseInsensitive();
|
||||
re_exact->MakeCaseInsensitive();
|
||||
}
|
||||
|
||||
int RE_Matcher::Compile(int lazy)
|
||||
{
|
||||
return re_anywhere->Compile(lazy) && re_exact->Compile(lazy);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue