forked from boostorg/regex
Fix /analyse errors from VC8.
Update test cases appropriately. [SVN r31988]
This commit is contained in:
@ -37,10 +37,29 @@ namespace{
|
|||||||
|
|
||||||
unsigned int magic_value = 25631;
|
unsigned int magic_value = 25631;
|
||||||
|
|
||||||
const char* names[] = {"REG_NOERROR", "REG_NOMATCH", "REG_BADPAT", "REG_ECOLLATE",
|
const char* names[] = {
|
||||||
"REG_ECTYPE", "REG_EESCAPE", "REG_ESUBREG", "REG_EBRACK",
|
"REG_NOERROR",
|
||||||
"REG_EPAREN", "REG_EBRACE", "REG_BADBR", "REG_ERANGE",
|
"REG_NOMATCH",
|
||||||
"REG_ESPACE", "REG_BADRPT", "REG_EMPTY", "REG_E_UNKNOWN"};
|
"REG_BADPAT",
|
||||||
|
"REG_ECOLLATE",
|
||||||
|
"REG_ECTYPE",
|
||||||
|
"REG_EESCAPE",
|
||||||
|
"REG_ESUBREG",
|
||||||
|
"REG_EBRACK",
|
||||||
|
"REG_EPAREN",
|
||||||
|
"REG_EBRACE",
|
||||||
|
"REG_BADBR",
|
||||||
|
"REG_ERANGE",
|
||||||
|
"REG_ESPACE",
|
||||||
|
"REG_BADRPT",
|
||||||
|
"REG_EEND",
|
||||||
|
"REG_ESIZE",
|
||||||
|
"REG_ERPAREN",
|
||||||
|
"REG_EMPTY",
|
||||||
|
"REG_ECOMPLEXITY",
|
||||||
|
"REG_ESTACK",
|
||||||
|
"REG_E_UNKNOWN",
|
||||||
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
|
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
|
||||||
|
@ -44,11 +44,29 @@ namespace {
|
|||||||
|
|
||||||
unsigned int wmagic_value = 28631;
|
unsigned int wmagic_value = 28631;
|
||||||
|
|
||||||
const wchar_t* wnames[] = {L"REG_NOERROR", L"REG_NOMATCH", L"REG_BADPAT", L"REG_ECOLLATE",
|
const wchar_t* wnames[] = {
|
||||||
L"REG_ECTYPE", L"REG_EESCAPE", L"REG_ESUBREG", L"REG_EBRACK",
|
L"REG_NOERROR",
|
||||||
L"REG_EPAREN", L"REG_EBRACE", L"REG_BADBR", L"REG_ERANGE",
|
L"REG_NOMATCH",
|
||||||
L"REG_ESPACE", L"REG_BADRPT", L"REG_EMPTY", L"REG_E_UNKNOWN"};
|
L"REG_BADPAT",
|
||||||
|
L"REG_ECOLLATE",
|
||||||
|
L"REG_ECTYPE",
|
||||||
|
L"REG_EESCAPE",
|
||||||
|
L"REG_ESUBREG",
|
||||||
|
L"REG_EBRACK",
|
||||||
|
L"REG_EPAREN",
|
||||||
|
L"REG_EBRACE",
|
||||||
|
L"REG_BADBR",
|
||||||
|
L"REG_ERANGE",
|
||||||
|
L"REG_ESPACE",
|
||||||
|
L"REG_BADRPT",
|
||||||
|
L"REG_EEND",
|
||||||
|
L"REG_ESIZE",
|
||||||
|
L"REG_ERPAREN",
|
||||||
|
L"REG_EMPTY",
|
||||||
|
L"REG_ECOMPLEXITY",
|
||||||
|
L"REG_ESTACK",
|
||||||
|
L"REG_E_UNKNOWN",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
||||||
|
@ -23,6 +23,13 @@
|
|||||||
#pragma warning(disable:4267)
|
#pragma warning(disable:4267)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||||
|
namespace std{
|
||||||
|
using ::atoi;
|
||||||
|
using ::wcstol;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int get_posix_compile_options(boost::regex_constants::syntax_option_type opts)
|
int get_posix_compile_options(boost::regex_constants::syntax_option_type opts)
|
||||||
{
|
{
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
@ -93,19 +100,23 @@ void test_deprecated(const char&, const test_regex_search_tag&)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// try and find the first occurance:
|
// try and find the first occurance:
|
||||||
boost::regmatch_t matches[50];
|
static const unsigned max_subs = 100;
|
||||||
if(boost::regexecA(&re, search_text.c_str(), 50, matches, posix_match_options) == 0)
|
boost::regmatch_t matches[max_subs];
|
||||||
|
if(boost::regexecA(&re, search_text.c_str(), max_subs, matches, posix_match_options) == 0)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(results[2*i] != -2)
|
while(results[2*i] != -2)
|
||||||
{
|
{
|
||||||
if(results[2*i] != matches[i].rm_so)
|
if(max_subs > i)
|
||||||
{
|
{
|
||||||
BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", char);
|
if(results[2*i] != matches[i].rm_so)
|
||||||
}
|
{
|
||||||
if(results[2*i+1] != matches[i].rm_eo)
|
BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", char);
|
||||||
{
|
}
|
||||||
BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", char);
|
if(results[2*i+1] != matches[i].rm_eo)
|
||||||
|
{
|
||||||
|
BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", char);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -213,19 +224,23 @@ void test_deprecated(const wchar_t&, const test_regex_search_tag&)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// try and find the first occurance:
|
// try and find the first occurance:
|
||||||
boost::regmatch_t matches[50];
|
static const unsigned max_subs = 100;
|
||||||
if(boost::regexecW(&re, search_text.c_str(), 50, matches, posix_match_options) == 0)
|
boost::regmatch_t matches[max_subs];
|
||||||
|
if(boost::regexecW(&re, search_text.c_str(), max_subs, matches, posix_match_options) == 0)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(results[2*i] != -2)
|
while(results[2*i] != -2)
|
||||||
{
|
{
|
||||||
if(results[2*i] != matches[i].rm_so)
|
if(max_subs > i)
|
||||||
{
|
{
|
||||||
BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", wchar_t);
|
if(results[2*i] != matches[i].rm_so)
|
||||||
}
|
{
|
||||||
if(results[2*i+1] != matches[i].rm_eo)
|
BOOST_REGEX_TEST_ERROR("Mismatch in start of subexpression " << i << " found with the POSIX C API.", wchar_t);
|
||||||
{
|
}
|
||||||
BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", wchar_t);
|
if(results[2*i+1] != matches[i].rm_eo)
|
||||||
|
{
|
||||||
|
BOOST_REGEX_TEST_ERROR("Mismatch in end of subexpression " << i << " found with the POSIX C API.", wchar_t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -253,11 +268,34 @@ void test_deprecated(const char&, const test_invalid_regex_tag&)
|
|||||||
|
|
||||||
// OK try and compile the expression:
|
// OK try and compile the expression:
|
||||||
boost::regex_tA re;
|
boost::regex_tA re;
|
||||||
if(boost::regcompA(&re, expression.c_str(), posix_options) == 0)
|
int code = boost::regcompA(&re, expression.c_str(), posix_options);
|
||||||
|
if(code == 0)
|
||||||
{
|
{
|
||||||
boost::regfreeA(&re);
|
boost::regfreeA(&re);
|
||||||
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", char);
|
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", char);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[100];
|
||||||
|
int s = boost::regerrorA(code, &re, 0, 0);
|
||||||
|
if(s < 100)
|
||||||
|
s = boost::regerrorA(code, &re, buf, 100);
|
||||||
|
s = boost::regerrorA(code | boost::REG_ITOA, &re, 0, 0);
|
||||||
|
if(s < 100)
|
||||||
|
{
|
||||||
|
s = boost::regerrorA(code | boost::REG_ITOA, &re, buf, 100);
|
||||||
|
re.re_endp = buf;
|
||||||
|
s = boost::regerrorA(code | boost::REG_ATOI, &re, buf, 100);
|
||||||
|
if(s)
|
||||||
|
{
|
||||||
|
int code2 = std::atoi(buf);
|
||||||
|
if(code2 != code)
|
||||||
|
{
|
||||||
|
BOOST_REGEX_TEST_ERROR("Got a bad error code from regerrA with REG_ATOI set: ", char);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// now try the RegEx class:
|
// now try the RegEx class:
|
||||||
//
|
//
|
||||||
@ -307,10 +345,33 @@ void test_deprecated(const wchar_t&, const test_invalid_regex_tag&)
|
|||||||
|
|
||||||
// OK try and compile the expression:
|
// OK try and compile the expression:
|
||||||
boost::regex_tW re;
|
boost::regex_tW re;
|
||||||
if(boost::regcompW(&re, expression.c_str(), posix_options) == 0)
|
int code = boost::regcompW(&re, expression.c_str(), posix_options);
|
||||||
|
if(code == 0)
|
||||||
{
|
{
|
||||||
boost::regfreeW(&re);
|
boost::regfreeW(&re);
|
||||||
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", wchar_t);
|
BOOST_REGEX_TEST_ERROR("Expression : \"" << expression.c_str() << "\" unexpectedly compiled with the POSIX C API.", wchar_t);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wchar_t buf[100];
|
||||||
|
int s = boost::regerrorW(code, &re, 0, 0);
|
||||||
|
if(s < 100)
|
||||||
|
s = boost::regerrorW(code, &re, buf, 100);
|
||||||
|
s = boost::regerrorW(code | boost::REG_ITOA, &re, 0, 0);
|
||||||
|
if(s < 100)
|
||||||
|
{
|
||||||
|
s = boost::regerrorW(code | boost::REG_ITOA, &re, buf, 100);
|
||||||
|
re.re_endp = buf;
|
||||||
|
s = boost::regerrorW(code | boost::REG_ATOI, &re, buf, 100);
|
||||||
|
if(s)
|
||||||
|
{
|
||||||
|
long code2 = std::wcstol(buf, 0, 10);
|
||||||
|
if(code2 != code)
|
||||||
|
{
|
||||||
|
BOOST_REGEX_TEST_ERROR("Got a bad error code from regerrW with REG_ATOI set: ", char);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,30 @@ void test_tricky_cases()
|
|||||||
TEST_REGEX_SEARCH("a(bbb+|bb+|b)bb", perl, "abbb", match_default, make_array(0, 4, 1, 2, -2, -2));
|
TEST_REGEX_SEARCH("a(bbb+|bb+|b)bb", perl, "abbb", match_default, make_array(0, 4, 1, 2, -2, -2));
|
||||||
TEST_REGEX_SEARCH("(.*).*", perl, "abcdef", match_default, make_array(0, 6, 0, 6, -2, 6, 6, 6, 6, -2, -2));
|
TEST_REGEX_SEARCH("(.*).*", perl, "abcdef", match_default, make_array(0, 6, 0, 6, -2, 6, 6, 6, 6, -2, -2));
|
||||||
TEST_REGEX_SEARCH("(a*)*", perl, "bc", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, -2));
|
TEST_REGEX_SEARCH("(a*)*", perl, "bc", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, -2));
|
||||||
|
TEST_REGEX_SEARCH("Z(((((((a+)+)+)+)+)+)+)+|Y(((((((a+)+)+)+)+)+)+)+|X(((((((a+)+)+)+)+)+)+)+|W(((((((a+)+)+)+)+)+)+)+|V(((((((a+)+)+)+)+)+)+)+|CZ(((((((a+)+)+)+)+)+)+)+|CY(((((((a+)+)+)+)+)+)+)+|CX(((((((a+)+)+)+)+)+)+)+|CW(((((((a+)+)+)+)+)+)+)+|CV(((((((a+)+)+)+)+)+)+)+|(a+)+", perl, "bc", match_default, make_array(-2, -2));
|
||||||
|
TEST_REGEX_SEARCH("Z(((((((a+)+)+)+)+)+)+)+|Y(((((((a+)+)+)+)+)+)+)+|X(((((((a+)+)+)+)+)+)+)+|W(((((((a+)+)+)+)+)+)+)+|V(((((((a+)+)+)+)+)+)+)+|CZ(((((((a+)+)+)+)+)+)+)+|CY(((((((a+)+)+)+)+)+)+)+|CX(((((((a+)+)+)+)+)+)+)+|CW(((((((a+)+)+)+)+)+)+)+|CV(((((((a+)+)+)+)+)+)+)+|(a+)+", perl, "aaa", match_default,
|
||||||
|
make_array(0, 3,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
0, 3,
|
||||||
|
-2, -2));
|
||||||
|
TEST_REGEX_SEARCH("Z(((((((a+)+)+)+)+)+)+)+|Y(((((((a+)+)+)+)+)+)+)+|X(((((((a+)+)+)+)+)+)+)+|W(((((((a+)+)+)+)+)+)+)+|V(((((((a+)+)+)+)+)+)+)+|CZ(((((((a+)+)+)+)+)+)+)+|CY(((((((a+)+)+)+)+)+)+)+|CX(((((((a+)+)+)+)+)+)+)+|CW(((((((a+)+)+)+)+)+)+)+|CV(((((((a+)+)+)+)+)+)+)+|(a+)+",
|
||||||
|
perl, "Zaaa", match_default,
|
||||||
|
make_array(0, 4,
|
||||||
|
1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
-1, -1,
|
||||||
|
-2, -2));
|
||||||
TEST_REGEX_SEARCH("xyx*xz", perl, "xyxxxxyxxxz", match_default, make_array(5, 11, -2, -2));
|
TEST_REGEX_SEARCH("xyx*xz", perl, "xyxxxxyxxxz", match_default, make_array(5, 11, -2, -2));
|
||||||
// do we get the right subexpression when it is used more than once?
|
// do we get the right subexpression when it is used more than once?
|
||||||
TEST_REGEX_SEARCH("a(b|c)*d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
TEST_REGEX_SEARCH("a(b|c)*d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
||||||
|
Reference in New Issue
Block a user