forked from boostorg/regex
Fix pattern escaping in regex used for \R so it works when the x-modifier is in effect.
Fixes: https://svn.boost.org/trac10/ticket/12960
This commit is contained in:
@ -330,11 +330,11 @@ inline const charT* get_escape_R_string()
|
|||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4309 4245)
|
# pragma warning(disable:4309 4245)
|
||||||
#endif
|
#endif
|
||||||
static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?',
|
static const charT e1[] = { '(', '?', '>', '\\', 'x', '0', 'D', '\\', 'x', '0', 'A', '?',
|
||||||
'|', '[', '\x0A', '\x0B', '\x0C', static_cast<unsigned char>('\x85'), '\\', 'x', '{', '2', '0', '2', '8', '}',
|
'|', '[', '\\', 'x', '0', 'A', '\\', 'x', '0', 'B', '\\', 'x', '0', 'C', static_cast<unsigned char>('\x85'), '\\', 'x', '{', '2', '0', '2', '8', '}',
|
||||||
'\\', 'x', '{', '2', '0', '2', '9', '}', ']', ')', '\0' };
|
'\\', 'x', '{', '2', '0', '2', '9', '}', ']', ')', '\0' };
|
||||||
static const charT e2[] = { '(', '?', '>', '\x0D', '\x0A', '?',
|
static const charT e2[] = { '(', '?', '>', '\\', 'x', '0', 'D', '\\', 'x', '0', 'A', '?',
|
||||||
'|', '[', '\x0A', '\x0B', '\x0C', static_cast<unsigned char>('\x85'), ']', ')', '\0' };
|
'|', '[', '\\', 'x', '0', 'A', '\\', 'x', '0', 'B', '\\', 'x', '0', 'C', static_cast<unsigned char>('\x85'), ']', ')', '\0' };
|
||||||
|
|
||||||
charT c = static_cast<charT>(0x2029u);
|
charT c = static_cast<charT>(0x2029u);
|
||||||
bool b = (static_cast<unsigned>(c) == 0x2029u);
|
bool b = (static_cast<unsigned>(c) == 0x2029u);
|
||||||
@ -352,8 +352,8 @@ inline const char* get_escape_R_string<char>()
|
|||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4309)
|
# pragma warning(disable:4309)
|
||||||
#endif
|
#endif
|
||||||
static const char e2[] = { '(', '?', '>', '\x0D', '\x0A', '?',
|
static const char e2[] = { '(', '?', '>', '\\', 'x', '0', 'D', '\\', 'x', '0', 'A', '?',
|
||||||
'|', '[', '\x0A', '\x0B', '\x0C', '\x85', ']', ')', '\0' };
|
'|', '[', '\\', 'x', '0', 'A', '\\', 'x', '0', 'B', '\\', 'x', '0', 'C', '\\', 'x', '8', '5', ']', ')', '\0' };
|
||||||
return e2;
|
return e2;
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
|
@ -155,12 +155,19 @@ void test_assertion_escapes()
|
|||||||
TEST_REGEX_SEARCH("\\R", perl, "foo\nbar", match_default, make_array(3, 4, -2, -2));
|
TEST_REGEX_SEARCH("\\R", perl, "foo\nbar", match_default, make_array(3, 4, -2, -2));
|
||||||
TEST_REGEX_SEARCH("\\R", perl, "foo\rbar", match_default, make_array(3, 4, -2, -2));
|
TEST_REGEX_SEARCH("\\R", perl, "foo\rbar", match_default, make_array(3, 4, -2, -2));
|
||||||
TEST_REGEX_SEARCH("\\R", perl, "foo\r\nbar", match_default, make_array(3, 5, -2, -2));
|
TEST_REGEX_SEARCH("\\R", perl, "foo\r\nbar", match_default, make_array(3, 5, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH("(?x) abc \\R", perl, "abc\r\nbar", match_default, make_array(0, 5, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH("(?x) abc \\R", perl, "abc\x0A" "bar", match_default, make_array(0, 4, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH("(?x) abc \\R", perl, "abc\x0B" "bar", match_default, make_array(0, 4, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH("(?x) abc \\R", perl, "abc\x0C" "bar", match_default, make_array(0, 4, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH("(?x) abc \\R", perl, "abc\x85" "bar", match_default, make_array(0, 4, -2, -2));
|
||||||
// see if \u works:
|
// see if \u works:
|
||||||
const wchar_t* w = L"\u2028";
|
const wchar_t* w = L"\u2028";
|
||||||
if(*w == 0x2028u)
|
if(*w == 0x2028u)
|
||||||
{
|
{
|
||||||
TEST_REGEX_SEARCH_W(L"\\R", perl, L"foo\u2028bar", match_default, make_array(3, 4, -2, -2));
|
TEST_REGEX_SEARCH_W(L"\\R", perl, L"foo\u2028bar", match_default, make_array(3, 4, -2, -2));
|
||||||
TEST_REGEX_SEARCH_W(L"\\R", perl, L"foo\u2029bar", match_default, make_array(3, 4, -2, -2));
|
TEST_REGEX_SEARCH_W(L"\\R", perl, L"foo\u2029bar", match_default, make_array(3, 4, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH_W(L"(?x) abc \\R", perl, L"abc\u2028bar", match_default, make_array(0, 4, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH_W(L"(?x) abc \\R", perl, L"abc\u2029bar", match_default, make_array(0, 4, -2, -2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user