mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/vern/case-insensitive-patterns'
* origin/topic/vern/case-insensitive-patterns: use PCRE syntax instead of the beautiful new (?i ...) syntax nitlet in NEWS entry test suite update for case-insensitive patterns document use of double quotes to escape case-insensitivity bug fix for recent memory leak patch documentation updates for case-insensitive patterns d'oh there's isalpha. I looked earlier for isletter :-P fix for handling [:(lower|upper):] in case-insensitive patterns implemented /re/i for case-insensitive patterns
This commit is contained in:
commit
463e540c9b
14 changed files with 235 additions and 40 deletions
24
src/RE.cc
24
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 )
|
||||
|
@ -155,9 +168,10 @@ int Specific_RE_Matcher::CompileSet(const string_list& set, const int_list& idx)
|
|||
|
||||
if ( set_nfa != nfa )
|
||||
Unref(set_nfa);
|
||||
Unref(nfa);
|
||||
nfa = 0;
|
||||
else
|
||||
Unref(nfa);
|
||||
|
||||
nfa = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -444,6 +458,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