forked from boostorg/regex
Remove limit on the number of backrefs possible.
Changes named sub-expressions to use different hashing scheme: high order bit is now always set to clashes between hashes and indexes don't happen until 2^30 or 2^62 sub-expressions in 32 and 64 bit code respectively. Changes bitmask of seen sub-expressions to use dynamic storage for sub-expression indexes above 64. Adds tests for the above. Fixes https://github.com/boostorg/regex/issues/75.
This commit is contained in:
@ -139,10 +139,10 @@ int cpp_main(int /*argc*/, char * /*argv*/[])
|
||||
|
||||
int* get_array_data()
|
||||
{
|
||||
static boost::thread_specific_ptr<boost::array<int, 200> > tp;
|
||||
static boost::thread_specific_ptr<boost::array<int, 800> > tp;
|
||||
|
||||
if(tp.get() == 0)
|
||||
tp.reset(new boost::array<int, 200>);
|
||||
tp.reset(new boost::array<int, 800>);
|
||||
|
||||
return tp.get()->data();
|
||||
}
|
||||
@ -160,9 +160,9 @@ const int* make_array(int first, ...)
|
||||
#ifdef TEST_THREADS
|
||||
int* data = get_array_data();
|
||||
#else
|
||||
static int data[200];
|
||||
static int data[800];
|
||||
#endif
|
||||
std::fill_n(data, 200, -2);
|
||||
std::fill_n(data, 800, -2);
|
||||
va_list ap;
|
||||
va_start(ap, first);
|
||||
//
|
||||
|
@ -103,5 +103,10 @@ void test_backrefs()
|
||||
TEST_REGEX_SEARCH("a(?'foo'(?'bar'(?'bb'(?'aa'b*))))c\\g{foo}d", perl, "abbcbbbd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?'foo'.)\\g{foo}", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?'foo'[bc])\\g{foo}d", perl, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2));
|
||||
|
||||
// Bug cases from https://github.com/boostorg/regex/issues/75
|
||||
TEST_REGEX_SEARCH("(?:(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)\\g{-1}|WORKING)", perl, "WORKING", match_default, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)(z)\\g{-1}|WORKING)", perl, "WORKING", match_default, make_array(0, 7, -2, -2));
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user