From 19d8e96cf5851319d87665123a2680ee63d7ab71 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 16 Oct 2001 11:36:47 +0000 Subject: [PATCH] Added workaround for Rogue Wave lib bug. [SVN r11391] --- include/boost/regex/detail/regex_match.hpp | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/include/boost/regex/detail/regex_match.hpp b/include/boost/regex/detail/regex_match.hpp index ef7632cc..f69e0292 100644 --- a/include/boost/regex/detail/regex_match.hpp +++ b/include/boost/regex/detail/regex_match.hpp @@ -34,6 +34,27 @@ namespace boost{ #pragma option push -a4 -b -Ve -pc -w-8026 #endif +// +// Unfortunately Rogue Waves standard library appears to have a bug +// in std::basic_string::compare that results in eroneous answers +// in some cases (tested with Borland C++ 5.1, Rogue Wave lib version +// 0x020101) the test case was: +// {39135,0} < {0xff,0} +// which succeeds when it should not. +// +#ifndef _RWSTD_VER +# define STR_COMP(s,p) s.compare(p) +#else +template +int string_compare(const std::basic_string& s, const C* p) +{ return s.compare(p); } +int string_compare(const std::string& s, const char* p) +{ return std::strcmp(s.c_str(), p); } +int string_compare(const std::wstring& s, const wchar_t* p) +{ return std::wcscmp(s.c_str(), p); } +# define STR_COMP(s,p) string_compare(s,p) +#endif + template iterator BOOST_REGEX_CALL re_is_set_member(iterator next, iterator last, @@ -104,11 +125,11 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, traits_inst.transform(s1, s2); for(i = 0; i < set_->cranges; ++i) { - if(s1 <= p) + if(STR_COMP(s1, p) <= 0) { while(*p)++p; ++p; - if(s1 >= p) + if(STR_COMP(s1, p) >= 0) return set_->isnot ? next : ++next; } else @@ -129,7 +150,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next, traits_inst.transform_primary(s1, s2); for(i = 0; i < set_->cequivalents; ++i) { - if(s1 == p) + if(STR_COMP(s1, p) == 0) return set_->isnot ? next : ++next; // skip string while(*p)++p;