mirror of
https://github.com/boostorg/regex.git
synced 2025-07-16 13:52:17 +02:00
Allow sort keys to contain nothing but a single NUL character (characters may be ignorable).
[SVN r27408]
This commit is contained in:
@ -407,6 +407,10 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
charT a2[3] = { c2.first, c2.second, charT(0), };
|
||||
s1 = this->m_traits.transform(a1, (a1[1] ? a1+2 : a1+1));
|
||||
s2 = this->m_traits.transform(a2, (a2[1] ? a2+2 : a2+1));
|
||||
if(s1.size() == 0)
|
||||
s1 = string_type(1, charT(0));
|
||||
if(s2.size() == 0)
|
||||
s2 = string_type(1, charT(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -546,7 +550,7 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!char_less<charT>(c1, c2))
|
||||
if(char_less<charT>(c2, c1))
|
||||
{
|
||||
// Oops error:
|
||||
return 0;
|
||||
|
@ -509,10 +509,8 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
||||
case sort_delim:
|
||||
// get a regular sort key, and then truncate everything after the delim:
|
||||
result.assign(this->m_pcollate->transform(p1, p2));
|
||||
if(result.size() && (result[0] == m_collate_delim))
|
||||
break;
|
||||
std::size_t i;
|
||||
for(i = 1; i < result.size(); ++i)
|
||||
for(i = 0; i < result.size(); ++i)
|
||||
{
|
||||
if(result[i] == m_collate_delim)
|
||||
break;
|
||||
@ -523,6 +521,11 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
||||
}catch(...){}
|
||||
while(result.size() && (charT(0) == *result.rbegin()))
|
||||
result.erase(result.size() - 1);
|
||||
if(result.empty())
|
||||
{
|
||||
// character is ignorable at the primary level:
|
||||
result = string_type(1, charT(0));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -68,11 +68,25 @@ inline bool can_start(wchar_t c, const unsigned char* map, unsigned char mask)
|
||||
#ifndef _RWSTD_VER
|
||||
template <class C, class T, class A>
|
||||
inline int string_compare(const std::basic_string<C,T,A>& s, const C* p)
|
||||
{ return s.compare(p); }
|
||||
{
|
||||
if(0 == *p)
|
||||
{
|
||||
if(s.empty() || ((s.size() == 1) && (s[0] == 0)))
|
||||
return 0;
|
||||
}
|
||||
return s.compare(p);
|
||||
}
|
||||
#else
|
||||
template <class C, class T, class A>
|
||||
inline int string_compare(const std::basic_string<C,T,A>& s, const C* p)
|
||||
{ return s.compare(p); }
|
||||
{
|
||||
if(0 == *p)
|
||||
{
|
||||
if(s.empty() || ((s.size() == 1) && (s[0] == 0)))
|
||||
return 0;
|
||||
}
|
||||
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
|
||||
|
@ -372,6 +372,8 @@ typename w32_regex_traits_implementation<charT>::string_type
|
||||
result.erase(i);
|
||||
break;
|
||||
}
|
||||
if(result.empty())
|
||||
result = string_type(1, charT(0));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user