From b84b17b3c4830827add6f1a799d6f6c4ad12c010 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 16 Dec 2003 13:06:01 +0000 Subject: [PATCH] Added BOOST_REGEX_V3 compatibilty workarounds. [SVN r21288] --- src/cregex.cpp | 4 ++++ src/posix_api.cpp | 2 ++ src/regex.cpp | 2 ++ src/wide_posix_api.cpp | 2 ++ test/regress/parse.cpp | 10 ++++++++-- test/regress/tests.cpp | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/cregex.cpp b/src/cregex.cpp index 9a49a4ed..bdfd751f 100644 --- a/src/cregex.cpp +++ b/src/cregex.cpp @@ -449,6 +449,10 @@ unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recu } #endif +#ifdef BOOST_REGEX_V3 +#define regex_replace regex_merge +#endif + std::string RegEx::Merge(const std::string& in, const std::string& fmt, bool copy, match_flag_type flags) { diff --git a/src/posix_api.cpp b/src/posix_api.cpp index f98cd660..56ef8552 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -61,7 +61,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char if(f & REG_NOCOLLATE) { flags |= regex::nocollate; +#ifndef BOOST_REGEX_V3 flags &= ~regex::collate; +#endif } if(f & REG_NOSUB) diff --git a/src/regex.cpp b/src/regex.cpp index 1c56c52c..ad8623f7 100644 --- a/src/regex.cpp +++ b/src/regex.cpp @@ -60,6 +60,7 @@ namespace re_detail{ // BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*ef*/, match_flag_type mf) { +#ifndef BOOST_REGEX_V3 // // can't mix match_extra with POSIX matching rules: // @@ -68,6 +69,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /* std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules"); throw_exception(msg); } +#endif } #ifdef BOOST_REGEX_HAS_MS_STACK_GUARD diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index e4313c88..fab55b1c 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -69,7 +69,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha if(f & REG_NOCOLLATE) { flags |= wregex::nocollate; +#ifndef BOOST_REGEX_V3 flags &= ~wregex::collate; +#endif } if(f & REG_NOSUB) diff --git a/test/regress/parse.cpp b/test/regress/parse.cpp index 43bf1b8e..26f6a34a 100644 --- a/test/regress/parse.cpp +++ b/test/regress/parse.cpp @@ -29,6 +29,11 @@ using namespace boost; +#ifdef BOOST_REGEX_V3 +#define regex_constants regbase +#endif + + // // start by defining all our flag types: @@ -63,9 +68,9 @@ flag_info flag_data[] = { { BOOST_RE_STR("bk_vbar"), 7, regex_constants::bk_vbar, 2 }, { BOOST_RE_STR("use_except"), 10, regex_constants::use_except, 2 }, { BOOST_RE_STR("literal"), 7, regex_constants::literal, 2 }, +#ifndef BOOST_REGEX_V3 { BOOST_RE_STR("nosubs"), 6, regex_constants::nosubs, 2 }, { BOOST_RE_STR("optimize"), 8, regex_constants::optimize, 2 }, -#ifndef BOOST_REGEX_V3 { BOOST_RE_STR("perlex"), 6, regex_constants::perlex, 2 }, #endif { BOOST_RE_STR("normal"), 6, regex_constants::normal, 2 }, @@ -87,9 +92,10 @@ flag_info flag_data[] = { { BOOST_RE_STR("match_not_null"), 14, match_not_null, 3 }, { BOOST_RE_STR("match_continuous"), 16, match_continuous, 3 }, { BOOST_RE_STR("match_partial"), 13, match_partial, 3 }, +#ifndef BOOST_REGEX_V3 { BOOST_RE_STR("match_nosubs"), 12, match_nosubs, 3 }, { BOOST_RE_STR("match_single_line"), 17, match_single_line, 3 }, - +#endif { BOOST_RE_STR("format_all"), 10, format_all, 3 }, { BOOST_RE_STR("format_sed"), 10, format_sed, 3 }, { BOOST_RE_STR("format_perl"), 11, format_perl, 3 }, diff --git a/test/regress/tests.cpp b/test/regress/tests.cpp index 78a6e11d..a6c2a999 100644 --- a/test/regress/tests.cpp +++ b/test/regress/tests.cpp @@ -434,12 +434,14 @@ void cpp_tests(const basic_regex& e, bool recurse = true) begin_error(); cout << "regex++ API result mismatch in regex_search(const std::string&, match_results&, const basic_regex&, int)" << endl; } +#ifndef BOOST_REGEX_V3 if(!regex_search(s2, e, static_cast(flags[3])) || !regex_search(s2.begin(), s2.end(), e, static_cast(flags[3]))) { begin_error(); cout << "regex++ API result mismatch in regex_search(const std::string&, const basic_regex&, int)" << endl; } +#endif // // partial match should give same result as full match // provided a full match is expected: @@ -476,11 +478,13 @@ void cpp_tests(const basic_regex& e, bool recurse = true) begin_error(); cout << "regex++ API result mismatch in regex_search(const char_t*, match_results&, const basic_regex&, int)" << endl; } +#ifndef BOOST_REGEX_V3 if(!regex_search(search_text.c_str(), e, static_cast(flags[3]))) { begin_error(); cout << "regex++ API result mismatch in regex_search(const char_t*, const basic_regex&, int)" << endl; } +#endif } } if((false == recurse) && (matches[0] == 0) && (matches[1] == static_cast(search_text.size())))