use PCRE syntax instead of the beautiful new (?i ...) syntax

This commit is contained in:
Vern Paxson 2018-06-29 13:01:05 -07:00
parent 726424f371
commit 85c4b0d285
6 changed files with 12 additions and 14 deletions

5
NEWS
View file

@ -262,9 +262,8 @@ New Functionality
yields F, though it yields T for "xfOObar".
You can achieve the same functionality for a subpattern enclosed in
parentheses by adding "+i" to the open parenthesis, optionally followed
by whitespace. So for example "/foo|(+i bar)/" will match "BaR", but
not "FoO".
parentheses by adding "?i:" to the open parenthesis. So for example
"/foo|(?i:bar)/" will match "BaR", but not "FoO".
For both ways of specifying case-insensitivity, characters enclosed in
double quotes maintain their case-sensitivity. So for example /"foo"/i

View file

@ -256,9 +256,8 @@ Here is a more detailed description of each type:
a "foo", "Foo", "BaR", etc.
You can also introduce a case-insensitive sub-pattern by enclosing it
in ``(+i``<pattern>``)``. For clarity, you can optionally include
trailing whitespace after the ``+i`` designator. So, for example,
``/foo|(+i bar)/`` will match "foo" and "BaR", but *not* "Foo".
in ``(?i:``<pattern>``)``. So, for example, ``/foo|(?i:bar)/`` will
match "foo" and "BaR", but *not* "Foo".
For both ways of specifying case-insensitivity, characters enclosed
in double quotes maintain their case-sensitivity. So for example

View file

@ -104,7 +104,7 @@ void Specific_RE_Matcher::AddPat(const char* new_pat,
void Specific_RE_Matcher::MakeCaseInsensitive()
{
const char fmt[] = "(+i %s)";
const char fmt[] = "(?i:%s)";
int n = strlen(pattern_text) + strlen(fmt);
char* s = new char[n + 5 /* slop */];

View file

@ -114,7 +114,7 @@ CCL_EXPR ("[:"[[:alpha:]]+":]")
}
}
"(+i"[ \t]* case_insensitive = 1; return TOK_CASE_INSENSITIVE;
"(?i:" case_insensitive = 1; return TOK_CASE_INSENSITIVE;
[a-zA-Z] {
if ( case_insensitive )

View file

@ -29,6 +29,6 @@ case-sensitive pattern (PASS)
/i pattern concatenation (FAIL)
/i pattern character class (FAIL)
/i pattern character class (PASS)
(+i ...) pattern construct (PASS)
(+i ...) pattern construct (FAIL)
(+i ...) pattern construct (PASS)
(?i:...) pattern construct (PASS)
(?i:...) pattern construct (FAIL)
(?i:...) pattern construct (PASS)

View file

@ -61,8 +61,8 @@ event bro_init()
test_case( "/i pattern character class", /ba[0a-c99S-Z0]/i & /bEz/ == "bArbEz" );
test_case( "/i pattern character class", /ba[0a-c99M-S0]/i & /bEz/ == "bArbEz" );
test_case( "(+i ...) pattern construct", /foo|(+i bar)/ in "xBAry" );
test_case( "(+i ...) pattern construct", /foo|(+i bar)/ in "xFOoy" );
test_case( "(+i ...) pattern construct", /foo|(+i bar)/ | /foo/i in "xFOoy" );
test_case( "(?i:...) pattern construct", /foo|(?i:bar)/ in "xBAry" );
test_case( "(?i:...) pattern construct", /foo|(?i:bar)/ in "xFOoy" );
test_case( "(?i:...) pattern construct", /foo|(?i:bar)/ | /foo/i in "xFOoy" );
}