Misc. new fixes:

Better support for BOOST_NO_WREGEX
Fixed bug in trailing null backrefs
Fixed bug in null repeat code
Fixed bug in negative forward lookahead assert when used as a prefix.


[SVN r17889]
This commit is contained in:
John Maddock
2003-03-13 12:50:54 +00:00
parent 86e5251979
commit 158c26d85c
3 changed files with 39 additions and 4 deletions

View File

@ -125,8 +125,10 @@
// If there isn't good enough wide character support then there will
// be no wide character regular expressions:
//
#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) && !defined(BOOST_NO_WREGEX)
# define BOOST_NO_WREGEX
#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
# if !defined(BOOST_NO_WREGEX)
# define BOOST_NO_WREGEX
# endif
#else
# if defined(__sgi) && defined(__SGI_STL_PORT)
// STLPort on IRIX is misconfigured: <cwctype> does not compile
@ -645,3 +647,4 @@ inline void pointer_construct(T* p, const T& t)

View File

@ -1990,6 +1990,8 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_re
{
case re_detail::syntax_element_startmark:
case re_detail::syntax_element_endmark:
if(static_cast<const re_detail::re_brace*>(dat)->index == -2)
return regbase::restart_any;
return probe_restart(dat->next.p);
case re_detail::syntax_element_start_line:
return regbase::restart_line;
@ -2070,6 +2072,10 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_le
return len;
}
return len;
case re_detail::syntax_element_startmark:
if(static_cast<const re_detail::re_brace*>(dat)->index == -2)
return 0;
// fall through:
default:
break;
}

View File

@ -56,8 +56,10 @@ inline int string_compare(const std::basic_string<C,T,A>& s, const C* p)
{ return s.compare(p); }
inline int string_compare(const std::string& s, const char* p)
{ return std::strcmp(s.c_str(), p); }
# ifndef BOOST_NO_WREGEX
inline int string_compare(const std::wstring& s, const wchar_t* p)
{ return std::wcscmp(s.c_str(), p); }
# endif
# define STR_COMP(s,p) string_compare(s,p)
#endif
@ -753,6 +755,15 @@ bool query_match_aux(iterator first,
start_loop[cur_acc] = first;
continue;
}
else if((unsigned int)accumulators[cur_acc] < static_cast<const re_repeat*>(ptr)->min)
{
// the repeat was null, and we haven't gone round min times yet,
// since all subsequent repeats will be null as well, just update
// our repeat count and skip out.
accumulators[cur_acc] = static_cast<const re_repeat*>(ptr)->min;
ptr = static_cast<const re_repeat*>(ptr)->alt.p;
continue;
}
goto failure;
}
// see if we can skip the repeat:
@ -809,6 +820,15 @@ bool query_match_aux(iterator first,
start_loop[cur_acc] = first;
continue;
}
else if((first == start_loop[cur_acc]) && accumulators[cur_acc] && ((unsigned int)accumulators[cur_acc] < static_cast<const re_repeat*>(ptr)->min))
{
// the repeat was null, and we haven't gone round min times yet,
// since all subsequent repeats will be null as well, just update
// our repeat count and skip out.
accumulators[cur_acc] = static_cast<const re_repeat*>(ptr)->min;
ptr = static_cast<const re_repeat*>(ptr)->alt.p;
continue;
}
// if we get here then neither option is allowed so fail:
goto failure;
@ -826,7 +846,7 @@ bool query_match_aux(iterator first,
if(flags & match_not_eob)
goto failure;
iterator p(first);
while((p != last) && traits_inst.is_separator(traits_inst.translate(*first, icase)))++p;
while((p != last) && traits_inst.is_separator(traits_inst.translate(*p, icase)))++p;
if(p != last)
goto failure;
ptr = ptr->next.p;
@ -958,6 +978,12 @@ bool query_match_aux(iterator first,
goto failure;
ptr = ptr->next.p;
continue;
case syntax_element_backref:
if(temp_match[static_cast<const re_brace*>(ptr)->index].first
!= temp_match[static_cast<const re_brace*>(ptr)->index].second)
goto failure;
ptr = ptr->next.p;
continue;
default:
goto failure;
}