forked from boostorg/regex
merged changes in regex5 branch
[SVN r26692]
This commit is contained in:
@ -21,9 +21,6 @@
|
||||
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
# include <boost/integer_traits.hpp>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_STD_STRING)
|
||||
#include <map>
|
||||
#include <list>
|
||||
@ -36,6 +33,12 @@ typedef boost::match_flag_type match_flag_type;
|
||||
#endif
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf; using ::strcpy; using ::strcat;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -54,7 +57,6 @@ namespace{
|
||||
template <class iterator>
|
||||
std::string to_string(iterator i, iterator j)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string s;
|
||||
while(i != j)
|
||||
{
|
||||
@ -108,7 +110,6 @@ public:
|
||||
|
||||
void RegExData::update()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
strings.erase(strings.begin(), strings.end());
|
||||
positions.erase(positions.begin(), positions.end());
|
||||
if(t == type_pc)
|
||||
@ -116,7 +117,7 @@ void RegExData::update()
|
||||
for(unsigned int i = 0; i < m.size(); ++i)
|
||||
{
|
||||
if(m[i].matched) strings[i] = std::string(m[i].first, m[i].second);
|
||||
positions[i] = m[i].matched ? m[i].first - pbase : RegEx::npos;
|
||||
positions[i] = m[i].matched ? m[i].first - pbase : -1;
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
@ -125,7 +126,7 @@ void RegExData::update()
|
||||
for(unsigned int i = 0; i < fm.size(); ++i)
|
||||
{
|
||||
if(fm[i].matched) strings[i] = to_string(fm[i].first, fm[i].second);
|
||||
positions[i] = fm[i].matched ? fm[i].first - fbase : RegEx::npos;
|
||||
positions[i] = fm[i].matched ? fm[i].first - fbase : -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -134,7 +135,6 @@ void RegExData::update()
|
||||
|
||||
void RegExData::clean()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
fbase = mapfile::iterator();
|
||||
fm = match_results<mapfile::iterator>();
|
||||
@ -145,54 +145,46 @@ void RegExData::clean()
|
||||
|
||||
RegEx::RegEx()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData();
|
||||
}
|
||||
|
||||
RegEx::RegEx(const RegEx& o)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData(*(o.pdata));
|
||||
}
|
||||
|
||||
RegEx::~RegEx()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
delete pdata;
|
||||
}
|
||||
|
||||
RegEx::RegEx(const char* c, bool icase)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData();
|
||||
SetExpression(c, icase);
|
||||
}
|
||||
|
||||
RegEx::RegEx(const std::string& s, bool icase)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata = new re_detail::RegExData();
|
||||
SetExpression(s.c_str(), icase);
|
||||
}
|
||||
|
||||
RegEx& RegEx::operator=(const RegEx& o)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
*pdata = *(o.pdata);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RegEx& RegEx::operator=(const char* p)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
SetExpression(p, false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int RegEx::SetExpression(const char* p, bool icase)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
boost::uint_fast32_t f = icase ? regex::normal | regex::use_except | regex::icase : regex::normal | regex::use_except;
|
||||
boost::uint_fast32_t f = icase ? regex::normal | regex::icase : regex::normal;
|
||||
return pdata->e.set_expression(p, f);
|
||||
}
|
||||
|
||||
@ -204,7 +196,6 @@ unsigned int RegEx::error_code()const
|
||||
|
||||
std::string RegEx::Expression()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return pdata->e.expression();
|
||||
}
|
||||
|
||||
@ -213,7 +204,6 @@ std::string RegEx::Expression()const
|
||||
//
|
||||
bool RegEx::Match(const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -229,7 +219,6 @@ bool RegEx::Match(const char* p, match_flag_type flags)
|
||||
|
||||
bool RegEx::Search(const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -257,7 +246,6 @@ struct pred1
|
||||
}
|
||||
unsigned int RegEx::Grep(GrepCallback cb, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -287,7 +275,6 @@ private:
|
||||
|
||||
unsigned int RegEx::Grep(std::vector<std::string>& v, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -317,7 +304,6 @@ private:
|
||||
}
|
||||
unsigned int RegEx::Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
pdata->pbase = p;
|
||||
const char* end = p;
|
||||
@ -350,7 +336,6 @@ struct pred4
|
||||
namespace{
|
||||
void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
file_iterator start(files);
|
||||
file_iterator end;
|
||||
if(recurse)
|
||||
@ -380,7 +365,7 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
|
||||
while(dstart != dend)
|
||||
{
|
||||
std::sprintf(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
(std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
BuildFileList(pl, buf, recurse);
|
||||
++dstart;
|
||||
}
|
||||
@ -395,7 +380,6 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
|
||||
unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int result = 0;
|
||||
std::list<std::string> file_list;
|
||||
BuildFileList(&file_list, files, recurse);
|
||||
@ -423,7 +407,6 @@ unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recur
|
||||
|
||||
unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int result = 0;
|
||||
std::list<std::string> file_list;
|
||||
BuildFileList(&file_list, files, recurse);
|
||||
@ -491,7 +474,6 @@ std::size_t RegEx::Split(std::vector<std::string>& v,
|
||||
//
|
||||
std::size_t RegEx::Position(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
@ -511,16 +493,14 @@ std::size_t RegEx::Position(int i)const
|
||||
return RegEx::npos;
|
||||
}
|
||||
|
||||
unsigned int RegEx::Marks()const
|
||||
std::size_t RegEx::Marks()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return pdata->e.mark_count();
|
||||
}
|
||||
|
||||
|
||||
std::size_t RegEx::Length(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
@ -542,7 +522,6 @@ std::size_t RegEx::Length(int i)const
|
||||
|
||||
bool RegEx::Matched(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
@ -565,7 +544,6 @@ bool RegEx::Matched(int i)const
|
||||
|
||||
std::string RegEx::What(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string result;
|
||||
switch(pdata->t)
|
||||
{
|
||||
@ -588,14 +566,10 @@ std::string RegEx::What(int i)const
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
const std::size_t RegEx::npos = ::boost::integer_traits<std::size_t>::const_max;
|
||||
#elif defined(BOOST_HAS_LONG_LONG)
|
||||
const std::size_t RegEx::npos = ~0ULL;
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
const std::size_t RegEx::npos = static_cast<std::size_t>(~0ULL);
|
||||
#else
|
||||
const std::size_t RegEx::npos = ~0UL;
|
||||
#endif
|
||||
const std::size_t RegEx::npos = static_cast<std::size_t>(~0UL);
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
Reference in New Issue
Block a user