@@ -10,10 +10,28 @@ void tester( char const (&str)[ N0 ] )
10
10
std::vector<char > s (N, ' \0 ' );
11
11
std::memcpy (s.data (), str, N);
12
12
boost::regex rx (s.begin (), s.end ());
13
- boost::match_results<std::string::const_iterator> what;
14
- std::string where (15 , ' H' );
15
- bool match = boost::regex_match (where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_perl);
16
- (void ) match;
13
+
14
+ std::vector<std::string> wheres;
15
+ wheres.push_back (std::string (15 , ' H' ));
16
+ wheres.push_back (" " );
17
+ wheres.push_back (" " );
18
+
19
+ // Perl-style matching
20
+ for (auto const & where : wheres) {
21
+ boost::match_results<std::string::const_iterator> what;
22
+ bool match = boost::regex_match (where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_perl);
23
+ (void ) match;
24
+ }
25
+
26
+ // POSIX-style matching
27
+ for (auto const & where : wheres) {
28
+ try {
29
+ boost::match_results<std::string::const_iterator> what;
30
+ bool match = boost::regex_match (where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_posix);
31
+ (void ) match;
32
+ } catch (...) {}
33
+ }
34
+
17
35
}
18
36
19
37
int main ()
@@ -22,9 +40,13 @@ int main()
22
40
// we keep a simple human-readable version
23
41
char const str1[] = " (Y(*COMMIT)|\\ K\\ D|.)+" ;
24
42
char const str2[] = " (Y(*COMMIT){||\\ K\\ D|||||||||\\ K|||ss|||||.|\232 *(?(50)\027\020 4657|H)\020 }\031\000 .* 6.'?-i)+[L??.\000\000\000\004\000\000\000\000 ?..<[\000\024 R]*+" ;
43
+ char const str3[] = " (Y(*COMMIT)\xFF\x80 |\\ L\\ K||||||||||.|||||\x84 |||||\x00\x00\x10 ||||||.* .'?-i)[L??...-i)[L??...[\x00\x14 R]*+" ;
44
+ char const str4[] = " (Y(*COMMIT)\x96 ||.* .* .\\ K|||\x9F ||||\x9C |.|||||\x84\x99 |||\x01\x00\x00\x00 |||'?-i#PL\x00\x01 .\x86 ??OMMIT)?...[\x00\x14 R]*+" ;
25
45
26
46
tester (str1);
27
47
tester (str2);
48
+ tester (str3);
49
+ tester (str4);
28
50
29
51
// prove that we catch certain impossible scenarios
30
52
0 commit comments