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:
jzmaddock
2020-01-19 11:28:36 +00:00
parent b5d60694cc
commit 4bb4d392e4
7 changed files with 81 additions and 20 deletions

View File

@ -70,13 +70,14 @@ void bubble_down_one(I first, I last)
}
}
static const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
template <class Iterator>
inline int hash_value_from_capture_name(Iterator i, Iterator j)
{
std::size_t r = boost::hash_range(i, j);
r %= ((std::numeric_limits<int>::max)() - 10001);
r += 10000;
return static_cast<int>(r);
r %= ((std::numeric_limits<int>::max)());
return static_cast<int>(r) | hash_value_mask;
}
class named_subexpressions