@@ -136,7 +139,7 @@
Revised
-
+
28 June 2004
© Copyright John Maddock 1998-
diff --git a/example/Jamfile b/example/Jamfile
index 1482c22c..e5bf07be 100644
--- a/example/Jamfile
+++ b/example/Jamfile
@@ -49,7 +49,7 @@ rule regex-test-run ( sources + : input * : requirements * )
run
# sources
$(sources)
- ../build/regex-options
+ ../build/regex-test-options
# dependencies
../build/boost_regex
diff --git a/include/boost/regex/icu.hpp b/include/boost/regex/icu.hpp
index b6de6dcd..167b8fd0 100644
--- a/include/boost/regex/icu.hpp
+++ b/include/boost/regex/icu.hpp
@@ -40,28 +40,28 @@ class BOOST_REGEX_DECL icu_regex_traits_implementation
typedef UChar32 char_type;
typedef std::size_t size_type;
typedef std::vector string_type;
- typedef ::Locale locale_type;
+ typedef U_NAMESPACE_QUALIFIER Locale locale_type;
typedef boost::uint_least32_t char_class_type;
public:
- icu_regex_traits_implementation(const ::Locale& l)
+ icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& l)
: m_locale(l)
{
UErrorCode success = U_ZERO_ERROR;
- m_collator.reset( ::Collator::createInstance(l, success));
+ m_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success));
if(U_SUCCESS(success) == 0)
init_error();
- m_collator->setStrength(::Collator::IDENTICAL);
+ m_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::IDENTICAL);
success = U_ZERO_ERROR;
- m_primary_collator.reset( ::Collator::createInstance(l, success));
+ m_primary_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success));
if(U_SUCCESS(success) == 0)
init_error();
- m_primary_collator->setStrength(::Collator::PRIMARY);
+ m_primary_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::PRIMARY);
}
- ::Locale getloc()const
+ U_NAMESPACE_QUALIFIER Locale getloc()const
{
return m_locale;
}
- string_type do_transform(const char_type* p1, const char_type* p2, const ::Collator* pcoll) const;
+ string_type do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const;
string_type transform(const char_type* p1, const char_type* p2) const
{
return do_transform(p1, p2, m_collator.get());
@@ -76,12 +76,12 @@ private:
std::runtime_error e("Could not initialize ICU resources");
boost::throw_exception(e);
}
- ::Locale m_locale; // The ICU locale that we're using
- boost::scoped_ptr< ::Collator> m_collator; // The full collation object
- boost::scoped_ptr< ::Collator> m_primary_collator; // The primary collation object
+ U_NAMESPACE_QUALIFIER Locale m_locale; // The ICU locale that we're using
+ boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator; // The full collation object
+ boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator; // The primary collation object
};
-inline boost::shared_ptr get_icu_regex_traits_implementation(const ::Locale& loc)
+inline boost::shared_ptr get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc)
{
return boost::shared_ptr(new icu_regex_traits_implementation(loc));
}
@@ -94,7 +94,7 @@ public:
typedef UChar32 char_type;
typedef std::size_t size_type;
typedef std::vector string_type;
- typedef ::Locale locale_type;
+ typedef U_NAMESPACE_QUALIFIER Locale locale_type;
#ifdef BOOST_NO_INT64_T
typedef std::bitset<64> char_class_type;
#else
@@ -104,7 +104,7 @@ public:
struct boost_extensions_tag{};
icu_regex_traits()
- : m_pimpl(re_detail::get_icu_regex_traits_implementation(::Locale()))
+ : m_pimpl(re_detail::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale()))
{
}
static size_type length(const char_type* p);
@@ -213,6 +213,7 @@ typedef match_results u16match;
//
namespace re_detail{
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
template
inline u32regex do_make_u32regex(InputIterator i,
InputIterator j,
@@ -241,7 +242,59 @@ inline u32regex do_make_u32regex(InputIterator i,
{
return u32regex(i, j, opt);
}
+#else
+template
+inline u32regex do_make_u32regex(InputIterator i,
+ InputIterator j,
+ boost::regex_constants::syntax_option_type opt,
+ const boost::mpl::int_<1>*)
+{
+ typedef boost::u8_to_u32_iterator conv_type;
+ typedef std::vector vector_type;
+ vector_type v;
+ conv_type a(i), b(j);
+ while(a != b)
+ {
+ v.push_back(*a);
+ ++a;
+ }
+ return u32regex(&*v.begin(), v.size(), opt);
+}
+template
+inline u32regex do_make_u32regex(InputIterator i,
+ InputIterator j,
+ boost::regex_constants::syntax_option_type opt,
+ const boost::mpl::int_<2>*)
+{
+ typedef boost::u16_to_u32_iterator conv_type;
+ typedef std::vector vector_type;
+ vector_type v;
+ conv_type a(i), b(j);
+ while(a != b)
+ {
+ v.push_back(*a);
+ ++a;
+ }
+ return u32regex(&*v.begin(), v.size(), opt);
+}
+
+template
+inline u32regex do_make_u32regex(InputIterator i,
+ InputIterator j,
+ boost::regex_constants::syntax_option_type opt,
+ const boost::mpl::int_<4>*)
+{
+ typedef std::vector vector_type;
+ vector_type v;
+ while(i != j)
+ {
+ v.push_back((UCHAR32)(*i));
+ ++a;
+ }
+ return u32regex(&*v.begin(), v.size(), opt);
+}
+#endif
}
//
@@ -721,7 +774,14 @@ OutputIterator do_regex_replace(OutputIterator out,
{
// unfortunately we have to copy the format string in order to pass in onward:
std::vector f;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
f.assign(fmt.first, fmt.second);
+#else
+ f.clear();
+ I2 pos = fmt.first;
+ while(pos != fmt.second)
+ f.push_back(*pos++);
+#endif
regex_iterator i(in.first, in.second, e, flags);
regex_iterator j;
@@ -773,7 +833,11 @@ inline OutputIterator u32regex_replace(OutputIterator out,
const charT* fmt,
match_flag_type flags = match_default)
{
- return re_detail::extract_output_base(
+ return re_detail::extract_output_base
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+
+#endif
+ (
re_detail::do_regex_replace(
re_detail::make_utf32_out(out, static_cast const*>(0)),
re_detail::make_utf32_seq(first, last, static_cast const*>(0)),
@@ -791,7 +855,11 @@ inline OutputIterator u32regex_replace(OutputIterator out,
const std::basic_string& fmt,
match_flag_type flags = match_default)
{
- return re_detail::extract_output_base(
+ return re_detail::extract_output_base
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+
+#endif
+ (
re_detail::do_regex_replace(
re_detail::make_utf32_out(out, static_cast const*>(0)),
re_detail::make_utf32_seq(first, last, static_cast const*>(0)),
@@ -809,7 +877,11 @@ inline OutputIterator u32regex_replace(OutputIterator out,
const UnicodeString& fmt,
match_flag_type flags = match_default)
{
- return re_detail::extract_output_base(
+ return re_detail::extract_output_base
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+
+#endif
+ (
re_detail::do_regex_replace(
re_detail::make_utf32_out(out, static_cast const*>(0)),
re_detail::make_utf32_seq(first, last, static_cast const*>(0)),
diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp
index 29e69b1b..edf7c688 100644
--- a/include/boost/regex/v4/basic_regex.hpp
+++ b/include/boost/regex/v4/basic_regex.hpp
@@ -242,10 +242,17 @@ public:
{
return assign(p, p + len, f);
}
-
+private:
+ basic_regex& do_assign(const charT* p1,
+ const charT* p2,
+ flag_type f);
+public:
basic_regex& assign(const charT* p1,
const charT* p2,
- flag_type f = regex_constants::normal);
+ flag_type f = regex_constants::normal)
+ {
+ return do_assign(p1, p2, f);
+ }
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
template
@@ -493,7 +500,7 @@ private:
// (in the event of a throw, the state of the object remains unchanged).
//
template
-basic_regex& basic_regex::assign(const charT* p1,
+basic_regex& basic_regex::do_assign(const charT* p1,
const charT* p2,
flag_type f)
{
diff --git a/include/boost/regex/v4/cpp_regex_traits.hpp b/include/boost/regex/v4/cpp_regex_traits.hpp
index 8911e69b..0e6e4aca 100644
--- a/include/boost/regex/v4/cpp_regex_traits.hpp
+++ b/include/boost/regex/v4/cpp_regex_traits.hpp
@@ -40,6 +40,7 @@
#endif
#include
+#include
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
diff --git a/include/boost/regex/v4/instances.hpp b/include/boost/regex/v4/instances.hpp
index 1af2bf67..9fcfa41a 100644
--- a/include/boost/regex/v4/instances.hpp
+++ b/include/boost/regex/v4/instances.hpp
@@ -57,7 +57,7 @@ template class BOOST_REGEX_DECL basic_regex< BOOST_REGEX_CHAR_T >;
# include BOOST_ABI_SUFFIX
#endif
-#elif defined(BOOST_MSVC) || defined(BOOST_INTEL) || (defined(__GNUC__) && (__GNUC__ >= 3))
+#elif defined(BOOST_MSVC) || defined(__ICL)
# ifndef BOOST_REGEX_INSTANTIATE
# ifdef __GNUC__
@@ -99,6 +99,53 @@ template class BOOST_REGEX_DECL ::boost::re_detail::perl_matcher< std::basic_str
# undef template
# endif
+#elif (defined(__GNUC__) && (__GNUC__ >= 3))
+
+# ifndef BOOST_REGEX_INSTANTIATE
+# define template __extension__ extern template
+# endif
+
+template BOOST_REGEX_DECL basic_regex&
+ basic_regex::do_assign(
+ const BOOST_REGEX_CHAR_T* p1,
+ const BOOST_REGEX_CHAR_T* p2,
+ flag_type f);
+template BOOST_REGEX_DECL basic_regex::locale_type BOOST_REGEX_CALL
+ basic_regex::imbue(locale_type l);
+
+template BOOST_REGEX_DECL void BOOST_REGEX_CALL
+ match_results::maybe_assign(
+ const match_results& m);
+
+
+template BOOST_REGEX_DECL void ::boost::re_detail::perl_matcher::allocator_type, boost::regex_traits >::construct_init(
+ BOOST_REGEX_CHAR_T const * first, BOOST_REGEX_CHAR_T const * end,
+ match_results& what,
+ const basic_regex& e,
+ match_flag_type f);
+template BOOST_REGEX_DECL bool ::boost::re_detail::perl_matcher::allocator_type, boost::regex_traits >::match();
+template BOOST_REGEX_DECL bool ::boost::re_detail::perl_matcher::allocator_type, boost::regex_traits >::find();
+
+#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
+// std:basic_string<>::const_iterator instances as well:
+template BOOST_REGEX_DECL void BOOST_REGEX_CALL
+ match_results::const_iterator>::maybe_assign(
+ const match_results::const_iterator>& m);
+
+template BOOST_REGEX_DECL void ::boost::re_detail::perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::construct_init(
+ std::basic_string::const_iterator first, std::basic_string::const_iterator end,
+ match_results::const_iterator>& what,
+ const basic_regex& e,
+ match_flag_type f);
+template BOOST_REGEX_DECL bool ::boost::re_detail::perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::match();
+template BOOST_REGEX_DECL bool ::boost::re_detail::perl_matcher::const_iterator, match_results< std::basic_string::const_iterator >::allocator_type, boost::regex_traits >::find();
+#endif
+
+# ifdef template
+# undef template
+# endif
+
+
#endif
} // namespace boost
diff --git a/include/boost/regex/v4/iterator_traits.hpp b/include/boost/regex/v4/iterator_traits.hpp
index 4c7674ad..7e247f53 100644
--- a/include/boost/regex/v4/iterator_traits.hpp
+++ b/include/boost/regex/v4/iterator_traits.hpp
@@ -71,6 +71,17 @@ template<>
struct regex_iterator_traits : pointer_iterator_traits{};
template<>
struct regex_iterator_traits : const_pointer_iterator_traits{};
+//
+// the follwoing are needed for ICU support:
+//
+template<>
+struct regex_iterator_traits : pointer_iterator_traits{};
+template<>
+struct regex_iterator_traits : const_pointer_iterator_traits{};
+template<>
+struct regex_iterator_traits : pointer_iterator_traits{};
+template<>
+struct regex_iterator_traits : const_pointer_iterator_traits{};
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
template<>
diff --git a/include/boost/regex/v4/perl_matcher.hpp b/include/boost/regex/v4/perl_matcher.hpp
index 8e9a4080..6a4fa1dc 100644
--- a/include/boost/regex/v4/perl_matcher.hpp
+++ b/include/boost/regex/v4/perl_matcher.hpp
@@ -68,6 +68,7 @@ inline bool can_start(wchar_t c, const unsigned char* map, unsigned char mask)
// which succeeds when it should not.
//
#ifndef _RWSTD_VER
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template
inline int string_compare(const std::basic_string& s, const C* p)
{
@@ -78,7 +79,9 @@ inline int string_compare(const std::basic_string& s, const C* p)
}
return s.compare(p);
}
+#endif
#else
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template
inline int string_compare(const std::basic_string& s, const C* p)
{
@@ -89,6 +92,7 @@ inline int string_compare(const std::basic_string& s, const C* p)
}
return s.compare(p);
}
+#endif
inline int string_compare(const std::string& s, const char* p)
{ return std::strcmp(s.c_str(), p); }
# ifndef BOOST_NO_WREGEX
@@ -96,7 +100,6 @@ inline int string_compare(const std::wstring& s, const wchar_t* p)
{ return std::wcscmp(s.c_str(), p); }
#endif
#endif
-#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template
inline int string_compare(const Seq& s, const C* p)
{
@@ -107,7 +110,6 @@ inline int string_compare(const Seq& s, const C* p)
}
return (i == s.size()) ? -p[i] : s[i] - p[i];
}
-#endif
# define STR_COMP(s,p) string_compare(s,p)
template
@@ -325,13 +327,7 @@ public:
match_flag_type f);
bool match();
- bool match_imp();
bool find();
- bool find_imp();
-#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
- typedef bool (perl_matcher::*protected_proc_type)();
- bool protected_call(protected_proc_type);
-#endif
void setf(match_flag_type f)
{ m_match_flags |= f; }
@@ -339,6 +335,16 @@ public:
{ m_match_flags &= ~f; }
private:
+ void construct_init(BidiIterator first, BidiIterator end,
+ match_results& what,
+ const basic_regex& e,
+ match_flag_type f);
+ bool find_imp();
+ bool match_imp();
+#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
+ typedef bool (perl_matcher::*protected_proc_type)();
+ bool protected_call(protected_proc_type);
+#endif
void estimate_max_state_count(std::random_access_iterator_tag*);
void estimate_max_state_count(void*);
bool match_prefix();
diff --git a/include/boost/regex/v4/perl_matcher_common.hpp b/include/boost/regex/v4/perl_matcher_common.hpp
index b7bd737e..5f4e6fa0 100644
--- a/include/boost/regex/v4/perl_matcher_common.hpp
+++ b/include/boost/regex/v4/perl_matcher_common.hpp
@@ -39,6 +39,15 @@ perl_matcher::perl_matcher(BidiIterator first,
: m_result(what), base(first), last(end),
position(first), re(e), traits_inst(e.get_traits()),
m_independent(false), next_count(&rep_obj), rep_obj(&next_count)
+{
+ construct_init(first, last, what, e, f);
+}
+
+template
+void perl_matcher::construct_init(BidiIterator first, BidiIterator end,
+ match_results& what,
+ const basic_regex& e,
+ match_flag_type f)
{
typedef typename regex_iterator_traits::iterator_category category;
diff --git a/include/boost/regex/v4/regex_raw_buffer.hpp b/include/boost/regex/v4/regex_raw_buffer.hpp
index 49f84020..6de7664a 100644
--- a/include/boost/regex/v4/regex_raw_buffer.hpp
+++ b/include/boost/regex/v4/regex_raw_buffer.hpp
@@ -26,6 +26,7 @@
#endif
#include
+#include
namespace boost{
namespace re_detail{
diff --git a/include/boost/regex/v4/u32regex_iterator.hpp b/include/boost/regex/v4/u32regex_iterator.hpp
index 950aa423..3491ed95 100644
--- a/include/boost/regex/v4/u32regex_iterator.hpp
+++ b/include/boost/regex/v4/u32regex_iterator.hpp
@@ -175,7 +175,8 @@ inline u32regex_iterator make_u32regex_iterator(const UChar* p, co
template
inline u32regex_iterator::const_iterator> make_u32regex_iterator(const std::basic_string& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
- return u32regex_iterator::const_iterator>(p.begin(), p.end(), e, m);
+ typedef typename std::basic_string::const_iterator iter_type;
+ return u32regex_iterator(p.begin(), p.end(), e, m);
}
inline u32regex_iterator make_u32regex_iterator(const UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
{
diff --git a/include/boost/regex/v4/u32regex_token_iterator.hpp b/include/boost/regex/v4/u32regex_token_iterator.hpp
index 58d1d046..f6e949f8 100644
--- a/include/boost/regex/v4/u32regex_token_iterator.hpp
+++ b/include/boost/regex/v4/u32regex_token_iterator.hpp
@@ -61,7 +61,9 @@ public:
: end(last), re(*p), flags(f){ subs.push_back(sub); }
u32regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector& v, match_flag_type f)
: end(last), re(*p), flags(f), subs(v){}
-#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+ // can't reliably get this to work....
+#elif (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|| BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \
|| BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500))
@@ -190,7 +192,9 @@ public:
if(!pdata->init(a))
pdata.reset();
}
-#if (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+ // can't reliably get this to work....
+#elif (BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)))\
|| BOOST_WORKAROUND(BOOST_MSVC, < 1300) \
|| BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) \
|| BOOST_WORKAROUND(__HP_aCC, BOOST_TESTED_AT(55500))
@@ -284,13 +288,15 @@ inline u32regex_token_iterator make_u32regex_token_iterator(const
template
inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
- return u32regex_token_iterator::const_iterator>(p.begin(), p.end(), e, m);
+ typedef typename std::basic_string::const_iterator iter_type;
+ return u32regex_token_iterator(p.begin(), p.end(), e, m);
}
inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, int submatch = 0, regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m);
}
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
// construction from a reference to an array:
template
inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
@@ -314,13 +320,15 @@ inline u32regex_token_iterator make_u32regex_token_iterator(const
template
inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
- return u32regex_token_iterator::const_iterator>(p.begin(), p.end(), e, m);
+ typedef typename std::basic_string::const_iterator iter_type;
+ return u32regex_token_iterator(p.begin(), p.end(), e, m);
}
template
inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default)
{
return u32regex_token_iterator(s.getBuffer(), s.getBuffer() + s.length(), e, submatch, m);
}
+#endif // BOOST_MSVC < 1300
// construction from a vector of sub_match id's:
inline u32regex_token_iterator make_u32regex_token_iterator(const char* p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
@@ -342,7 +350,8 @@ inline u32regex_token_iterator make_u32regex_token_iterator(const
template
inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
- return u32regex_token_iterator::const_iterator>(p.begin(), p.end(), e, m);
+ typedef typename std::basic_string::const_iterator iter_type;
+ return u32regex_token_iterator(p.begin(), p.end(), e, m);
}
inline u32regex_token_iterator make_u32regex_token_iterator(const UnicodeString& s, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default)
{
diff --git a/src/icu.cpp b/src/icu.cpp
index 776f2cce..8ad9afc7 100644
--- a/src/icu.cpp
+++ b/src/icu.cpp
@@ -25,12 +25,18 @@ namespace boost{
namespace re_detail{
-icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const ::Collator* pcoll) const
+icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const
{
// TODO make thread safe!!!! :
typedef u32_to_u16_iterator itt;
itt i(p1), j(p2);
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
std::vector< ::UChar> t(i, j);
+#else
+ std::vector< ::UChar> t;
+ while(i != j)
+ t.push_back(*i++);
+#endif
::uint8_t result[100];
::int32_t len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result));
if(std::size_t(len) > sizeof(result))
@@ -39,11 +45,29 @@ icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do
len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1);
if((0 == presult[len-1]) && (len > 1))
--len;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
return string_type(presult.get(), presult.get()+len);
+#else
+ string_type sresult;
+ ::uint8_t const* ia = presult.get();
+ ::uint8_t const* ib = presult.get()+len;
+ while(ia != ib)
+ sresult.push_back(*ia++);
+ return sresult;
+#endif
}
if((0 == result[len-1]) && (len > 1))
--len;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
return string_type(result, result+len);
+#else
+ string_type sresult;
+ ::uint8_t const* ia = result;
+ ::uint8_t const* ib = result+len;
+ while(ia != ib)
+ sresult.push_back(*ia++);
+ return sresult;
+#endif
}
}
@@ -390,7 +414,14 @@ icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_ty
string_type result;
if(std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2)
{
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
std::string s(p1, p2);
+#else
+ std::string s;
+ const char_type* p3 = p1;
+ while(p3 != p2)
+ s.append(1, *p3++);
+#endif
// Try Unicode name:
UErrorCode err = U_ZERO_ERROR;
UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err);
@@ -409,7 +440,16 @@ icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_ty
}
// try POSIX name:
s = ::boost::re_detail::lookup_default_collate_name(s);
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
result.assign(s.begin(), s.end());
+#else
+ result.clear();
+ std::string::const_iterator si, sj;
+ si = s.begin();
+ sj = s.end();
+ while(si != sj)
+ result.push_back(*si++);
+#endif
}
if(result.empty() && (p2-p1 == 1))
result.push_back(*p1);
diff --git a/test/regress/test_icu.cpp b/test/regress/test_icu.cpp
index 9aa09fa9..f3fac09b 100644
--- a/test/regress/test_icu.cpp
+++ b/test/regress/test_icu.cpp
@@ -25,6 +25,44 @@
#include
#include "test.hpp"
+namespace unnecessary_fix{
+//
+// Some outrageously broken std lib's don't have a conforming
+// back_insert_iterator, which means we can't use the std version
+// as an argument to regex_replace, sigh... use our own:
+//
+template
+class back_insert_iterator
+#ifndef BOOST_NO_STD_ITERATOR
+ : public std::iterator
+#endif
+{
+private:
+ Seq* container;
+ typedef const typename Seq::value_type value_type;
+public:
+ typedef Seq container_type;
+ typedef std::output_iterator_tag iterator_category;
+
+ explicit back_insert_iterator(Seq& x) : container(&x) {}
+ back_insert_iterator& operator=(const value_type& val)
+ {
+ container->push_back(val);
+ return *this;
+ }
+ back_insert_iterator& operator*() { return *this; }
+ back_insert_iterator& operator++() { return *this; }
+ back_insert_iterator operator++(int) { return *this; }
+};
+
+template
+inline back_insert_iterator back_inserter(Seq& x)
+{
+ return back_insert_iterator(x);
+}
+
+}
+
//
// compare two match_results struct's for equality,
// converting the iterator as needed:
@@ -32,7 +70,9 @@
template
void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<2> const*)
{
- typedef boost::u16_to_u32_iterator iterator_type;
+ typedef typename MR2::value_type MR2_value_type;
+ typedef typename MR2_value_type::const_iterator MR2_iterator_type;
+ typedef boost::u16_to_u32_iterator iterator_type;
typedef typename MR1::size_type size_type;
if(w1.size() != w2.size())
{
@@ -60,7 +100,9 @@ void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<2> const*)
template
void compare_result(const MR1& w1, const MR2& w2, boost::mpl::int_<1> const*)
{
- typedef boost::u8_to_u32_iterator iterator_type;
+ typedef typename MR2::value_type MR2_value_type;
+ typedef typename MR2_value_type::const_iterator MR2_iterator_type;
+ typedef boost::u8_to_u32_iterator iterator_type;
typedef typename MR1::size_type size_type;
if(w1.size() != w2.size())
{
@@ -150,23 +192,35 @@ void test_icu(const wchar_t&, const test_regex_search_tag& )
boost::u32regex r;
if(*test_locale::c_str())
{
- ::Locale l(test_locale::c_str());
+ U_NAMESPACE_QUALIFIER Locale l(test_locale::c_str());
if(l.isBogus())
return;
r.imbue(l);
}
std::vector< ::UChar32> expression;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression.assign(test_info::expression().begin(), test_info::expression().end());
+#else
+ std::copy(test_info::expression().begin(), test_info::expression().end(), std::back_inserter(expression));
+#endif
boost::regex_constants::syntax_option_type syntax_options = test_info::syntax_options();
try{
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
r.assign(expression.begin(), expression.end(), syntax_options);
+#else
+ r.assign(&*expression.begin(), expression.size(), syntax_options);
+#endif
if(r.status())
{
BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done, error code = " << r.status(), UChar32);
}
std::vector< ::UChar32> search_text;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
search_text.assign(test_info::search_text().begin(), test_info::search_text().end());
+#else
+ std::copy(test_info::search_text().begin(), test_info::search_text().end(), std::back_inserter(search_text));
+#endif
boost::regex_constants::match_flag_type opts = test_info::match_options();
const int* answer_table = test_info::answer_table();
boost::match_results::const_iterator> what;
@@ -194,8 +248,15 @@ void test_icu(const wchar_t&, const test_regex_search_tag& )
std::vector expression16, text16;
boost::match_results::const_iterator> what16;
boost::match_results what16c;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression16.assign(u16_conv(expression.begin()), u16_conv(expression.end()));
text16.assign(u16_conv(search_text.begin()), u16_conv(search_text.end()));
+#else
+ expression16.clear();
+ std::copy(u16_conv(expression.begin()), u16_conv(expression.end()), std::back_inserter(expression16));
+ text16.clear();
+ std::copy(u16_conv(search_text.begin()), u16_conv(search_text.end()), std::back_inserter(text16));
+#endif
r = boost::make_u32regex(expression16.begin(), expression16.end(), syntax_options);
if(boost::u32regex_search(const_cast&>(text16).begin(), const_cast&>(text16).end(), what16, r, opts))
{
@@ -231,8 +292,15 @@ void test_icu(const wchar_t&, const test_regex_search_tag& )
std::vector expression8, text8;
boost::match_results::const_iterator> what8;
boost::match_results what8c;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression8.assign(u8_conv(expression.begin()), u8_conv(expression.end()));
text8.assign(u8_conv(search_text.begin()), u8_conv(search_text.end()));
+#else
+ expression8.clear();
+ std::copy(u8_conv(expression.begin()), u8_conv(expression.end()), std::back_inserter(expression8));
+ text8.clear();
+ std::copy(u8_conv(search_text.begin()), u8_conv(search_text.end()), std::back_inserter(text8));
+#endif
r = boost::make_u32regex(expression8.begin(), expression8.end(), syntax_options);
if(boost::u32regex_search(const_cast&>(text8).begin(), const_cast&>(text8).end(), what8, r, opts))
{
@@ -289,12 +357,16 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
{
typedef boost::u16_to_u32_iterator conv_iterator;
std::vector< ::UChar32> expression;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression.assign(test_info::expression().begin(), test_info::expression().end());
+#else
+ std::copy(test_info::expression().begin(), test_info::expression().end(), std::back_inserter(expression));
+#endif
boost::regex_constants::syntax_option_type syntax_options = test_info::syntax_options();
boost::u32regex r;
if(*test_locale::c_str())
{
- ::Locale l(test_locale::c_str());
+ U_NAMESPACE_QUALIFIER Locale l(test_locale::c_str());
if(l.isBogus())
return;
r.imbue(l);
@@ -304,7 +376,11 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
//
try
{
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
if(0 == r.assign(expression.begin(), expression.end(), syntax_options | boost::regex_constants::no_except).status())
+#else
+ if(0 == r.assign(&*expression.begin(), expression.size(), syntax_options | boost::regex_constants::no_except).status())
+#endif
{
BOOST_REGEX_TEST_ERROR("Expression compiled when it should not have done so.", wchar_t);
}
@@ -318,7 +394,11 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
//
bool have_catch = false;
try{
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
r.assign(expression.begin(), expression.end(), syntax_options);
+#else
+ r.assign(&*expression.begin(), expression.size(), syntax_options);
+#endif
#ifdef BOOST_NO_EXCEPTIONS
if(r.status())
have_catch = true;
@@ -356,7 +436,11 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
//
typedef boost::u32_to_u16_iterator::const_iterator> u16_conv;
std::vector expression16;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression16.assign(u16_conv(expression.begin()), u16_conv(expression.end()));
+#else
+ std::copy(u16_conv(expression.begin()), u16_conv(expression.end()), std::back_inserter(expression16));
+#endif
if(0 == boost::make_u32regex(expression16.begin(), expression16.end(), syntax_options | boost::regex_constants::no_except).status())
{
BOOST_REGEX_TEST_ERROR("Expression compiled when it should not have done so.", wchar_t);
@@ -374,7 +458,11 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
//
typedef boost::u32_to_u8_iterator::const_iterator> u8_conv;
std::vector expression8;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression8.assign(u8_conv(expression.begin()), u8_conv(expression.end()));
+#else
+ std::copy(u8_conv(expression.begin()), u8_conv(expression.end()), std::back_inserter(expression8));
+#endif
if(0 == boost::make_u32regex(expression8.begin(), expression8.end(), syntax_options | boost::regex_constants::no_except).status())
{
BOOST_REGEX_TEST_ERROR("Expression compiled when it should not have done so.", wchar_t);
@@ -393,27 +481,42 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
void test_icu(const wchar_t&, const test_regex_replace_tag&)
{
std::vector< ::UChar32> expression;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression.assign(test_info::expression().begin(), test_info::expression().end());
+#else
+ std::copy(test_info::expression().begin(), test_info::expression().end(), std::back_inserter(expression));
+#endif
boost::regex_constants::syntax_option_type syntax_options = test_info::syntax_options();
boost::u32regex r;
try{
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
r.assign(expression.begin(), expression.end(), syntax_options);
+#else
+ r.assign(&*expression.begin(), expression.size(), syntax_options);
+#endif
if(r.status())
{
BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done, error code = " << r.status(), UChar32);
}
typedef std::vector string_type;
string_type search_text;
- search_text.assign(test_info::search_text().begin(), test_info::search_text().end());
boost::regex_constants::match_flag_type opts = test_info::match_options();
string_type format_string;
+ string_type result_string;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
+ search_text.assign(test_info::search_text().begin(), test_info::search_text().end());
format_string.assign(test_info::format_string().begin(), test_info::format_string().end());
format_string.push_back(0);
- string_type result_string;
result_string.assign(test_info::result_string().begin(), test_info::result_string().end());
+#else
+ std::copy(test_info::search_text().begin(), test_info::search_text().end(), std::back_inserter(search_text));
+ std::copy(test_info::format_string().begin(), test_info::format_string().end(), std::back_inserter(format_string));
+ format_string.push_back(0);
+ std::copy(test_info::result_string().begin(), test_info::result_string().end(), std::back_inserter(result_string));
+#endif
string_type result;
- boost::u32regex_replace(std::back_inserter(result), search_text.begin(), search_text.end(), r, &*format_string.begin(), opts);
+ boost::u32regex_replace(unnecessary_fix::back_inserter(result), search_text.begin(), search_text.end(), r, &*format_string.begin(), opts);
if(result != result_string)
{
BOOST_REGEX_TEST_ERROR("regex_replace generated an incorrect string result", UChar32);
@@ -428,12 +531,19 @@ void test_icu(const wchar_t&, const test_regex_replace_tag&)
//
typedef boost::u32_to_u16_iterator::const_iterator> u16_conv;
std::vector expression16, text16, format16, result16, found16;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression16.assign(u16_conv(expression.begin()), u16_conv(expression.end()));
text16.assign(u16_conv(search_text.begin()), u16_conv(search_text.end()));
format16.assign(u16_conv(format_string.begin()), u16_conv(format_string.end()));
result16.assign(u16_conv(result_string.begin()), u16_conv(result_string.end()));
+#else
+ std::copy(u16_conv(expression.begin()), u16_conv(expression.end()), std::back_inserter(expression16));
+ std::copy(u16_conv(search_text.begin()), u16_conv(search_text.end()), std::back_inserter(text16));
+ std::copy(u16_conv(format_string.begin()), u16_conv(format_string.end()), std::back_inserter(format16));
+ std::copy(u16_conv(result_string.begin()), u16_conv(result_string.end()), std::back_inserter(result16));
+#endif
r = boost::make_u32regex(expression16.begin(), expression16.end(), syntax_options);
- boost::u32regex_replace(std::back_inserter(found16), text16.begin(), text16.end(), r, &*format16.begin(), opts);
+ boost::u32regex_replace(unnecessary_fix::back_inserter(found16), text16.begin(), text16.end(), r, &*format16.begin(), opts);
if(result16 != found16)
{
BOOST_REGEX_TEST_ERROR("u32regex_replace with UTF-16 string returned incorrect result", UChar32);
@@ -458,12 +568,19 @@ void test_icu(const wchar_t&, const test_regex_replace_tag&)
//
typedef boost::u32_to_u8_iterator::const_iterator, unsigned char> u8_conv;
std::vector expression8, text8, format8, result8, found8;
+#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
expression8.assign(u8_conv(expression.begin()), u8_conv(expression.end()));
text8.assign(u8_conv(search_text.begin()), u8_conv(search_text.end()));
format8.assign(u8_conv(format_string.begin()), u8_conv(format_string.end()));
result8.assign(u8_conv(result_string.begin()), u8_conv(result_string.end()));
+#else
+ std::copy(u8_conv(expression.begin()), u8_conv(expression.end()), std::back_inserter(expression8));
+ std::copy(u8_conv(search_text.begin()), u8_conv(search_text.end()), std::back_inserter(text8));
+ std::copy(u8_conv(format_string.begin()), u8_conv(format_string.end()), std::back_inserter(format8));
+ std::copy(u8_conv(result_string.begin()), u8_conv(result_string.end()), std::back_inserter(result8));
+#endif
r = boost::make_u32regex(expression8.begin(), expression8.end(), syntax_options);
- boost::u32regex_replace(std::back_inserter(found8), text8.begin(), text8.end(), r, &*format8.begin(), opts);
+ boost::u32regex_replace(unnecessary_fix::back_inserter(found8), text8.begin(), text8.end(), r, &*format8.begin(), opts);
if(result8 != found8)
{
BOOST_REGEX_TEST_ERROR("u32regex_replace with UTF-8 string returned incorrect result", UChar32);
diff --git a/test/regress/test_unicode.cpp b/test/regress/test_unicode.cpp
index ddd07fd3..f84aa3ab 100644
--- a/test/regress/test_unicode.cpp
+++ b/test/regress/test_unicode.cpp
@@ -122,10 +122,14 @@ void test_unicode()
TEST_REGEX_CLASS_U(Line Separator, 2028);
TEST_REGEX_CLASS_U(Zp, 2029);
TEST_REGEX_CLASS_U(Paragraph Separator, 2029);
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+ // Some tests have to be disabled for VC6 because the compiler
+ // mangles the string literals...
TEST_REGEX_CLASS_U(C*, 009F);
TEST_REGEX_CLASS_U(Other, 009F);
TEST_REGEX_CLASS_U(Cc, 009F);
TEST_REGEX_CLASS_U(Control, 009F);
+#endif
TEST_REGEX_CLASS_U(Cf, FFFB);
TEST_REGEX_CLASS_U(Format, FFFB);
//TEST_REGEX_CLASS_U(Cs, DC00);
@@ -147,14 +151,18 @@ void test_unicode()
TEST_REGEX_SEARCH_U(L"[\\N{MODIFIER LETTER LOW ACUTE ACCENT}]", perl, L"\x02CF", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH_U(L"[\\N{SUPERSCRIPT ONE}]", perl, L"\x00B9", match_default, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH_U(L"\\N{CJK UNIFIED IDEOGRAPH-7FED}", perl, L"\x7FED", match_default, make_array(0, 1, -2, -2));
-
+#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+ // Some tests have to be disabled for VC6 because the compiler
+ // mangles the string literals...
TEST_REGEX_SEARCH_U(L"\\w+", perl, L" e\x301" L"coute ", match_default, make_array(1, 8, -2, -2));
+
TEST_REGEX_SEARCH_U(L"^", perl, L" \x2028 \x2029 \x000D\x000A \x000A \x000C \x000D \x0085 ",
match_default | match_not_bol, make_array(2, 2, -2, 4, 4, -2, 7, 7, -2, 9, 9, -2, 11, 11, -2, 13, 13, -2, 15, 15, -2, -2));
TEST_REGEX_SEARCH_U(L"$", perl, L" \x2028 \x2029 \x000D\x000A \x000A \x000C \x000D \x0085 ",
match_default | match_not_eol, make_array(1, 1, -2, 3, 3, -2, 5, 5, -2, 8, 8, -2, 10, 10, -2, 12, 12, -2, 14, 14, -2, -2));
TEST_REGEX_SEARCH_U(L".", perl, L" \x2028\x2029\x000D\x000A\x000A\x000C\x000D\x0085 ",
match_default | match_not_dot_newline, make_array(0, 1, -2, 9, 10, -2, -2));
+#endif
}
#else