forked from boostorg/regex
First cut at new v5 regex version, doesn't really work yet, but all the infrastructure is in place...
[SVN r22489]
This commit is contained in:
1 parent
99d5760d2b
commit
4d2d3a1450
65 files changed
+5155
-7075
No files matched your search
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE cpp_regex_traits.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Implements cpp_regex_traits<char> (and associated helper classes).
|
||||
*/
|
||||
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
void cpp_regex_traits_char_layer<char>::init()
|
||||
{
|
||||
// we need to start by initialising our syntax map so we know which
|
||||
// character is used for which purpose:
|
||||
std::memset(m_char_map, 0, sizeof(m_char_map));
|
||||
#ifndef __IBMCPP__
|
||||
std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
|
||||
#else
|
||||
std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
|
||||
#endif
|
||||
std::string cat_name(cpp_regex_traits<char>::get_catalog_name());
|
||||
if(cat_name.size())
|
||||
{
|
||||
cat = this->m_pmessages->open(
|
||||
cat_name,
|
||||
this->m_locale);
|
||||
if((int)cat < 0)
|
||||
{
|
||||
std::string m("Unable to open message catalog: ");
|
||||
std::runtime_error err(m + cat_name);
|
||||
boost::throw_exception(err);
|
||||
}
|
||||
}
|
||||
//
|
||||
// if we have a valid catalog then load our messages:
|
||||
//
|
||||
if((int)cat >= 0)
|
||||
{
|
||||
try{
|
||||
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i));
|
||||
for(string_type::size_type j = 0; j < mss.size(); ++j)
|
||||
{
|
||||
m_char_map[static_cast<unsigned char>(mss[j])] = i;
|
||||
}
|
||||
}
|
||||
this->m_pmessages->close(cat);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
this->m_pmessages->close(cat);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
const char* ptr = get_default_syntax(i);
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
m_char_map[static_cast<unsigned char>(*ptr)] = i;
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// finish off by calculating our escape types:
|
||||
//
|
||||
unsigned char i = 'A';
|
||||
do
|
||||
{
|
||||
if(m_char_map[i] == 0)
|
||||
{
|
||||
if(this->m_pctype->is(std::ctype_base::lower, i))
|
||||
m_char_map[i] = regex_constants::escape_type_class;
|
||||
else if(this->m_pctype->is(std::ctype_base::upper, i))
|
||||
m_char_map[i] = regex_constants::escape_type_not_class;
|
||||
}
|
||||
}while(0xFF != i++);
|
||||
}
|
||||
|
||||
} // re_detail
|
||||
} // boost
|
||||
+2
-27
@@ -51,7 +51,6 @@ namespace{
|
||||
template <class iterator>
|
||||
std::string to_string(iterator i, iterator j)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string s;
|
||||
while(i != j)
|
||||
{
|
||||
@@ -105,7 +104,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)
|
||||
@@ -131,7 +129,6 @@ void RegExData::update()
|
||||
|
||||
void RegExData::clean()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
fbase = mapfile::iterator();
|
||||
fm = match_results<mapfile::iterator>();
|
||||
@@ -142,54 +139,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);
|
||||
}
|
||||
|
||||
@@ -201,7 +190,6 @@ unsigned int RegEx::error_code()const
|
||||
|
||||
std::string RegEx::Expression()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return pdata->e.expression();
|
||||
}
|
||||
|
||||
@@ -210,7 +198,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;
|
||||
@@ -226,7 +213,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;
|
||||
@@ -254,7 +240,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;
|
||||
@@ -284,7 +269,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;
|
||||
@@ -314,7 +298,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;
|
||||
@@ -347,7 +330,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)
|
||||
@@ -392,7 +374,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);
|
||||
@@ -420,7 +401,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);
|
||||
@@ -488,7 +468,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:
|
||||
@@ -508,16 +487,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:
|
||||
@@ -539,7 +516,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:
|
||||
@@ -562,7 +538,6 @@ bool RegEx::Matched(int i)const
|
||||
|
||||
std::string RegEx::What(int i)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::string result;
|
||||
switch(pdata->t)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,6 @@ const char* _fi_sep_alt = _fi_sep;
|
||||
|
||||
void mapfile::open(const char* file)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#if defined(__CYGWIN__)||defined(__CYGWIN32__)
|
||||
char win32file[ MAX_PATH ];
|
||||
cygwin_conv_to_win32_path( file, win32file );
|
||||
@@ -110,7 +109,6 @@ void mapfile::open(const char* file)
|
||||
|
||||
void mapfile::close()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
UnmapViewOfFile((void*)_first);
|
||||
@@ -125,7 +123,6 @@ void mapfile::close()
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(file && node)
|
||||
file->unlock(node);
|
||||
file = i.file;
|
||||
@@ -138,7 +135,6 @@ mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i)
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator++ ()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((++offset == mapfile::buf_size) && file)
|
||||
{
|
||||
++node;
|
||||
@@ -151,7 +147,6 @@ mapfile_iterator& mapfile_iterator::operator++ ()
|
||||
|
||||
mapfile_iterator mapfile_iterator::operator++ (int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(*this);
|
||||
if((++offset == mapfile::buf_size) && file)
|
||||
{
|
||||
@@ -165,7 +160,6 @@ mapfile_iterator mapfile_iterator::operator++ (int)
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator-- ()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((offset == 0) && file)
|
||||
{
|
||||
--node;
|
||||
@@ -180,7 +174,6 @@ mapfile_iterator& mapfile_iterator::operator-- ()
|
||||
|
||||
mapfile_iterator mapfile_iterator::operator-- (int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(*this);
|
||||
if((offset == 0) && file)
|
||||
{
|
||||
@@ -196,7 +189,6 @@ mapfile_iterator mapfile_iterator::operator-- (int)
|
||||
|
||||
mapfile_iterator operator + (const mapfile_iterator& i, long off)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(i);
|
||||
temp += off;
|
||||
return temp;
|
||||
@@ -204,7 +196,6 @@ mapfile_iterator operator + (const mapfile_iterator& i, long off)
|
||||
|
||||
mapfile_iterator operator - (const mapfile_iterator& i, long off)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
mapfile_iterator temp(i);
|
||||
temp -= off;
|
||||
return temp;
|
||||
@@ -212,19 +203,16 @@ mapfile_iterator operator - (const mapfile_iterator& i, long off)
|
||||
|
||||
mapfile::iterator mapfile::begin()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return mapfile_iterator(this, 0);
|
||||
}
|
||||
|
||||
mapfile::iterator mapfile::end()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
return mapfile_iterator(this, _size);
|
||||
}
|
||||
|
||||
void mapfile::lock(pointer* node)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
assert(node >= _first);
|
||||
assert(node <= _last);
|
||||
if(node < _last)
|
||||
@@ -265,7 +253,6 @@ void mapfile::lock(pointer* node)const
|
||||
|
||||
void mapfile::unlock(pointer* node)const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
assert(node >= _first);
|
||||
assert(node <= _last);
|
||||
if(node < _last)
|
||||
@@ -279,7 +266,6 @@ void mapfile::unlock(pointer* node)const
|
||||
|
||||
long int get_file_length(std::FILE* hfile)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
long int result;
|
||||
std::fseek(hfile, 0, SEEK_END);
|
||||
result = std::ftell(hfile);
|
||||
@@ -290,7 +276,6 @@ long int get_file_length(std::FILE* hfile)
|
||||
|
||||
void mapfile::open(const char* file)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
hfile = std::fopen(file, "rb");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
@@ -325,7 +310,6 @@ void mapfile::open(const char* file)
|
||||
|
||||
void mapfile::close()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(hfile != 0)
|
||||
{
|
||||
pointer* p = _first;
|
||||
@@ -350,7 +334,6 @@ void mapfile::close()
|
||||
|
||||
file_iterator::file_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -381,7 +364,6 @@ file_iterator::file_iterator()
|
||||
|
||||
file_iterator::file_iterator(const char* wild)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -450,7 +432,6 @@ file_iterator::file_iterator(const char* wild)
|
||||
|
||||
file_iterator::file_iterator(const file_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -478,7 +459,6 @@ file_iterator::file_iterator(const file_iterator& other)
|
||||
|
||||
file_iterator& file_iterator::operator=(const file_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::strcpy(_root, other._root);
|
||||
std::strcpy(_path, other._path);
|
||||
ptr = _path + (other.ptr - other._path);
|
||||
@@ -496,7 +476,6 @@ file_iterator& file_iterator::operator=(const file_iterator& other)
|
||||
|
||||
file_iterator::~file_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
delete[] _root;
|
||||
delete[] _path;
|
||||
if(--(ref->count) == 0)
|
||||
@@ -509,7 +488,6 @@ file_iterator::~file_iterator()
|
||||
|
||||
file_iterator file_iterator::operator++(int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
file_iterator temp(*this);
|
||||
next();
|
||||
return temp;
|
||||
@@ -518,7 +496,6 @@ file_iterator file_iterator::operator++(int)
|
||||
|
||||
void file_iterator::next()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(ref->hf != _fi_invalid_handle)
|
||||
{
|
||||
bool cont = true;
|
||||
@@ -545,7 +522,6 @@ void file_iterator::next()
|
||||
|
||||
directory_iterator::directory_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -576,7 +552,6 @@ directory_iterator::directory_iterator()
|
||||
|
||||
directory_iterator::directory_iterator(const char* wild)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -643,7 +618,6 @@ directory_iterator::directory_iterator(const char* wild)
|
||||
|
||||
directory_iterator::~directory_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
delete[] _root;
|
||||
delete[] _path;
|
||||
if(--(ref->count) == 0)
|
||||
@@ -656,7 +630,6 @@ directory_iterator::~directory_iterator()
|
||||
|
||||
directory_iterator::directory_iterator(const directory_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -684,7 +657,6 @@ directory_iterator::directory_iterator(const directory_iterator& other)
|
||||
|
||||
directory_iterator& directory_iterator::operator=(const directory_iterator& other)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::strcpy(_root, other._root);
|
||||
std::strcpy(_path, other._path);
|
||||
ptr = _path + (other.ptr - other._path);
|
||||
@@ -701,7 +673,6 @@ directory_iterator& directory_iterator::operator=(const directory_iterator& othe
|
||||
|
||||
directory_iterator directory_iterator::operator++(int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
directory_iterator temp(*this);
|
||||
next();
|
||||
return temp;
|
||||
@@ -709,7 +680,6 @@ directory_iterator directory_iterator::operator++(int)
|
||||
|
||||
void directory_iterator::next()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(ref->hf != _fi_invalid_handle)
|
||||
{
|
||||
bool cont = true;
|
||||
@@ -748,7 +718,6 @@ struct _fi_priv_data
|
||||
|
||||
_fi_priv_data::_fi_priv_data(const char* p)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::strcpy(root, p);
|
||||
mask = root;
|
||||
while(*mask) ++mask;
|
||||
@@ -775,7 +744,6 @@ _fi_priv_data::_fi_priv_data(const char* p)
|
||||
|
||||
bool iswild(const char* mask, const char* name)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
while(*mask && *name)
|
||||
{
|
||||
switch(*mask)
|
||||
@@ -817,7 +785,6 @@ bool iswild(const char* mask, const char* name)
|
||||
|
||||
unsigned _fi_attributes(const char* root, const char* name)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
char buf[MAX_PATH];
|
||||
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
|
||||
std::sprintf(buf, "%s%s", root, name);
|
||||
@@ -834,7 +801,6 @@ unsigned _fi_attributes(const char* root, const char* name)
|
||||
|
||||
_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_fi_find_handle dat = new _fi_priv_data(lpFileName);
|
||||
|
||||
DIR* h = opendir(dat->root);
|
||||
@@ -850,7 +816,6 @@ _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindF
|
||||
|
||||
bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
dirent* d;
|
||||
do
|
||||
{
|
||||
@@ -868,7 +833,6 @@ bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData)
|
||||
|
||||
bool _fi_FindClose(_fi_find_handle dat)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
closedir(dat->d);
|
||||
delete dat;
|
||||
return true;
|
||||
|
||||
+6
-14
@@ -35,7 +35,6 @@ const char* names[] = {"REG_NOERROR", "REG_NOMATCH", "REG_BADPAT", "REG_ECOLLATE
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic != magic_value)
|
||||
{
|
||||
expression->guts = 0;
|
||||
@@ -54,7 +53,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
#endif
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regex::extended : regex::basic;
|
||||
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||
// and translate those that are actually set:
|
||||
|
||||
@@ -74,13 +73,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
if(f & REG_ICASE)
|
||||
flags |= regex::icase;
|
||||
if(f & REG_ESCAPE_IN_LISTS)
|
||||
flags |= regex::escape_in_lists;
|
||||
flags &= ~regex::no_escape_in_lists;
|
||||
if(f & REG_NEWLINE_ALT)
|
||||
flags |= regex::newline_alt;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
if(f & REG_PERLEX)
|
||||
flags |= regex::perlex;
|
||||
#endif
|
||||
|
||||
const char* p2;
|
||||
if(f & REG_PEND)
|
||||
@@ -110,12 +105,11 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
|
||||
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* e, char* buf, regsize_t buf_size)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t result = 0;
|
||||
if(code & REG_ITOA)
|
||||
{
|
||||
code &= ~REG_ITOA;
|
||||
if(code <= REG_E_UNKNOWN)
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
{
|
||||
result = std::strlen(names[code]) + 1;
|
||||
if(buf_size >= result)
|
||||
@@ -129,7 +123,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
char localbuf[5];
|
||||
if(e == 0)
|
||||
return 0;
|
||||
for(int i = 0; i <= REG_E_UNKNOWN; ++i)
|
||||
for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i)
|
||||
{
|
||||
if(std::strcmp(e->re_endp, names[i]) == 0)
|
||||
{
|
||||
@@ -144,7 +138,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
std::strcpy(buf, localbuf);
|
||||
return std::strlen(localbuf) + 1;
|
||||
}
|
||||
if(code <= REG_E_UNKNOWN)
|
||||
if(code <= (int)REG_E_UNKNOWN)
|
||||
{
|
||||
std::string p;
|
||||
if((e) && (e->re_magic == magic_value))
|
||||
@@ -168,7 +162,6 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, const char* buf, regsize_t n, regmatch_t* array, int eflags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
bool result = false;
|
||||
match_flag_type flags = match_default | expression->eflags;
|
||||
const char* end;
|
||||
@@ -209,7 +202,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
if(result)
|
||||
{
|
||||
// extract what matched:
|
||||
unsigned int i;
|
||||
std::size_t i;
|
||||
for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i)
|
||||
{
|
||||
array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf);
|
||||
@@ -228,7 +221,6 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic == magic_value)
|
||||
{
|
||||
delete static_cast<regex*>(expression->guts);
|
||||
|
||||
+4
-12
@@ -46,12 +46,6 @@ namespace boost{
|
||||
bad_pattern::~bad_pattern() throw() {}
|
||||
bad_expression::~bad_expression() throw() {}
|
||||
|
||||
regbase::regbase()
|
||||
: _flags(regbase::failbit){}
|
||||
|
||||
regbase::regbase(const regbase& b)
|
||||
: _flags(b._flags){}
|
||||
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
@@ -118,12 +112,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& msg)
|
||||
{
|
||||
bad_expression e(msg);
|
||||
throw_exception(e);
|
||||
}
|
||||
|
||||
#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3)
|
||||
|
||||
#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0
|
||||
@@ -140,7 +128,11 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p)
|
||||
|
||||
#else
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
|
||||
#else
|
||||
mem_block_cache block_cache = { 0, 0, };
|
||||
#endif
|
||||
|
||||
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
|
||||
{
|
||||
|
||||
+1
-194
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Copyright (c) 1998-2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
@@ -21,199 +21,6 @@
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#ifdef BOOST_REGEX_DEBUG
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_raw_buffer.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_raw_buffer.hpp>
|
||||
#endif
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#ifndef BOOST_RE_OLD_IOSTREAM
|
||||
#include <ostream>
|
||||
#else
|
||||
#include <ostream.h>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace re_detail {
|
||||
std::ostream& operator<<(std::ostream& s, syntax_element_type x)
|
||||
{
|
||||
return s << static_cast<unsigned long>(x);
|
||||
}
|
||||
}} // namespace boost::re_detail
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
char b1[32] = {0,};
|
||||
char guard_pattern[32]
|
||||
= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, };
|
||||
char b2[32] = {0,};
|
||||
|
||||
static const int guard_size = 32;
|
||||
|
||||
bool check_pattern(void* p)
|
||||
{
|
||||
return p ? memcmp(p, guard_pattern, guard_size) : 0;
|
||||
}
|
||||
|
||||
inline unsigned maxi(unsigned i, unsigned j)
|
||||
{
|
||||
return i < j ? j : i;
|
||||
}
|
||||
|
||||
unsigned int allocated = 0;
|
||||
|
||||
struct init
|
||||
{
|
||||
init();
|
||||
~init();
|
||||
};
|
||||
|
||||
init::init()
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_DELAY_FREE_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
}
|
||||
|
||||
init::~init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
init i;
|
||||
|
||||
void* get_mem(size_t n)
|
||||
{
|
||||
++allocated;
|
||||
char* p = (char*)malloc(n + guard_size * 2 + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + boost::re_detail::padding_size);
|
||||
char* base = p;
|
||||
p = (char*)((std::ptrdiff_t)(p + boost::re_detail::padding_mask) & ~boost::re_detail::padding_mask);
|
||||
std::memcpy(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size), guard_pattern, guard_size);
|
||||
std::memcpy(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + guard_size + n, guard_pattern, guard_size);
|
||||
*(int*)p = n;
|
||||
*(void**)(p + sizeof(int)) = base;
|
||||
return p + guard_size + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size);
|
||||
}
|
||||
|
||||
void free_mem(void* b)
|
||||
{
|
||||
if(b)
|
||||
{
|
||||
char* p = (char*)b;
|
||||
p -= (guard_size + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size));
|
||||
if(check_pattern(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size)) || check_pattern(p + maxi(sizeof(int) + sizeof(void*), boost::re_detail::padding_size) + guard_size + *(int*)p))
|
||||
{
|
||||
cerr << "Error: freed memory has been written past end..." << endl;
|
||||
}
|
||||
free(*(void**)(p + sizeof(int)));
|
||||
--allocated;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void* operator new(size_t n)
|
||||
{
|
||||
return get_mem(n);
|
||||
}
|
||||
|
||||
void* operator new[](size_t n)
|
||||
{
|
||||
return get_mem(n);
|
||||
}
|
||||
|
||||
void operator delete(void* p)
|
||||
{
|
||||
free_mem(p);
|
||||
}
|
||||
|
||||
void operator delete[](void* p)
|
||||
{
|
||||
free_mem(p);
|
||||
}
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
std::set<debug_guard*, std::less<debug_guard*> >* patterns = 0;
|
||||
|
||||
int pattern_count = 0;
|
||||
|
||||
void check_patterns(const char* f, int l)
|
||||
{
|
||||
if(pattern_count)
|
||||
{
|
||||
std::set<debug_guard*, std::less<debug_guard*> >::iterator i, j;
|
||||
i = patterns->begin();
|
||||
j = patterns->end();
|
||||
while(i != j)
|
||||
{
|
||||
if(check_pattern((void*)(*i)->g1) || check_pattern((*i)->g2) || check_pattern((void*)(*i)->pc) || check_pattern((*i)->pnc))
|
||||
{
|
||||
cerr << "Error: static memory corruption at " << hex << *i << dec << " in " << (*i)->file << "@" << (*i)->line << " called from " << f << "@" << l << endl;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug_guard::debug_guard(const char* f, int l, const char* p1, char* p2)
|
||||
{
|
||||
if(++pattern_count == 1)
|
||||
patterns = new std::set<debug_guard*, std::less<debug_guard*> >;
|
||||
file = f;
|
||||
line = l;
|
||||
std::memcpy(g1, guard_pattern, guard_size);
|
||||
std::memcpy(g2, guard_pattern, guard_size);
|
||||
if(p1)
|
||||
{
|
||||
pc = p1;
|
||||
}
|
||||
else
|
||||
pc = 0;
|
||||
if(p2)
|
||||
{
|
||||
pnc = p2;
|
||||
std::memcpy(pnc, guard_pattern, guard_size);
|
||||
}
|
||||
else
|
||||
pnc = 0;
|
||||
patterns->insert(this);
|
||||
}
|
||||
|
||||
debug_guard::~debug_guard()
|
||||
{
|
||||
check_patterns(file, line);
|
||||
if(check_pattern(g1) || check_pattern(g2))
|
||||
{
|
||||
cerr << "Error: memory corruption " << file << "@" << line << endl;
|
||||
}
|
||||
patterns->erase(this);
|
||||
if(--pattern_count == 0)
|
||||
{
|
||||
delete patterns;
|
||||
patterns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace re_detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// regex configuration information: this prints out the settings used
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
|
||||
#include <boost/regex/v4/regex_raw_buffer.hpp>
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
void BOOST_REGEX_CALL raw_storage::resize(size_type n)
|
||||
{
|
||||
register size_type newsize = start ? last - start : 1024;
|
||||
while(newsize < n)
|
||||
newsize *= 2;
|
||||
register size_type datasize = end - start;
|
||||
// extend newsize to WORD/DWORD boundary:
|
||||
newsize = (newsize + padding_mask) & ~(padding_mask);
|
||||
|
||||
// allocate and copy data:
|
||||
register pointer ptr = static_cast<pointer>(::operator new(newsize));
|
||||
BOOST_REGEX_NOEH_ASSERT(ptr)
|
||||
std::memcpy(ptr, start, datasize);
|
||||
|
||||
// get rid of old buffer:
|
||||
::operator delete(start);
|
||||
|
||||
// and set up pointers:
|
||||
start = ptr;
|
||||
end = ptr + datasize;
|
||||
last = ptr + newsize;
|
||||
}
|
||||
|
||||
void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n)
|
||||
{
|
||||
BOOST_ASSERT(pos <= size_type(end - start));
|
||||
if(size_type(last - end) < n)
|
||||
resize(n + (end - start));
|
||||
register void* result = start + pos;
|
||||
std::memmove(start + pos + n, start + pos, (end - start) - pos);
|
||||
end += n;
|
||||
return result;
|
||||
}
|
||||
|
||||
}} // namespaces
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1998-2002
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE: regex_synch.cpp
|
||||
* VERSION: see <boost/version.hpp>
|
||||
* DESCRIPTION: Thread synch helper functions, for regular
|
||||
* expression library.
|
||||
*/
|
||||
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_synch.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_synch.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
void BOOST_REGEX_CALL re_init_threads()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
if(p_re_lock == 0)
|
||||
p_re_lock = new critical_section();
|
||||
cs_guard g(*p_re_lock);
|
||||
++re_lock_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL re_free_threads()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
cs_guard g(*p_re_lock);
|
||||
--re_lock_count;
|
||||
if(re_lock_count == 0)
|
||||
{
|
||||
g.acquire(false);
|
||||
delete p_re_lock;
|
||||
p_re_lock = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
|
||||
BOOST_REGEX_DECL critical_section* p_re_lock = 0;
|
||||
|
||||
BOOST_REGEX_DECL unsigned int re_lock_count = 0;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace re_detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE regex_traits_defaults.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Declares API's for access to regex_traits default properties.
|
||||
*/
|
||||
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
|
||||
namespace boost{ namespace re_detail{
|
||||
|
||||
const char* get_default_syntax(regex_constants::syntax_type n)
|
||||
{
|
||||
// if the user hasn't supplied a message catalog, then this supplies
|
||||
// default "messages" for us to load in the range 1-100.
|
||||
const char* messages[] = {
|
||||
"",
|
||||
"(",
|
||||
")",
|
||||
"$",
|
||||
"^",
|
||||
".",
|
||||
"*",
|
||||
"+",
|
||||
"?",
|
||||
"[",
|
||||
"]",
|
||||
"|",
|
||||
"\\",
|
||||
"#",
|
||||
"-",
|
||||
"{",
|
||||
"}",
|
||||
"0123456789",
|
||||
"b",
|
||||
"B",
|
||||
"<",
|
||||
">",
|
||||
"",
|
||||
"",
|
||||
"A",
|
||||
"z",
|
||||
"\n",
|
||||
",",
|
||||
"a",
|
||||
"f",
|
||||
"n",
|
||||
"r",
|
||||
"t",
|
||||
"v",
|
||||
"x",
|
||||
"c",
|
||||
":",
|
||||
"=",
|
||||
"e",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"E",
|
||||
"Q",
|
||||
"X",
|
||||
"C",
|
||||
"Z",
|
||||
"G"
|
||||
"!", };
|
||||
|
||||
return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]);
|
||||
}
|
||||
|
||||
const char* get_default_error_string(regex_constants::error_type n)
|
||||
{
|
||||
static const char* const s_default_error_messages[] = {
|
||||
"Success", /* REG_NOERROR */
|
||||
"No match", /* REG_NOMATCH */
|
||||
"Invalid regular expression", /* REG_BADPAT */
|
||||
"Invalid collation character", /* REG_ECOLLATE */
|
||||
"Invalid character class name", /* REG_ECTYPE */
|
||||
"Trailing backslash", /* REG_EESCAPE */
|
||||
"Invalid back reference", /* REG_ESUBREG */
|
||||
"Unmatched [ or [^", /* REG_EBRACK */
|
||||
"Unmatched ( or \\(", /* REG_EPAREN */
|
||||
"Unmatched \\{", /* REG_EBRACE */
|
||||
"Invalid content of \\{\\}", /* REG_BADBR */
|
||||
"Invalid range end", /* REG_ERANGE */
|
||||
"Memory exhausted", /* REG_ESPACE */
|
||||
"Invalid preceding regular expression", /* REG_BADRPT */
|
||||
"Premature end of regular expression", /* REG_EEND */
|
||||
"Regular expression too big", /* REG_ESIZE */
|
||||
"Unmatched ) or \\)", /* REG_ERPAREN */
|
||||
"Empty expression", /* REG_EMPTY */
|
||||
"Complexity requirements exceeded", /* REG_ECOMPLEXITY */
|
||||
"Out of stack space", /* REG_ESTACK */
|
||||
"Unknown error", /* REG_E_UNKNOWN */
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
return (n <= REG_E_UNKNOWN) ? s_default_error_messages[REG_E_UNKNOWN] : s_default_error_messages[n];
|
||||
}
|
||||
|
||||
bool is_combining_implementation(boost::uint_least16_t c)
|
||||
{
|
||||
const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
|
||||
0x0483, 0x0486,
|
||||
0x0903, 0x0903,
|
||||
0x093E, 0x0940,
|
||||
0x0949, 0x094C,
|
||||
0x0982, 0x0983,
|
||||
0x09BE, 0x09C0,
|
||||
0x09C7, 0x09CC,
|
||||
0x09D7, 0x09D7,
|
||||
0x0A3E, 0x0A40,
|
||||
0x0A83, 0x0A83,
|
||||
0x0ABE, 0x0AC0,
|
||||
0x0AC9, 0x0ACC,
|
||||
0x0B02, 0x0B03,
|
||||
0x0B3E, 0x0B3E,
|
||||
0x0B40, 0x0B40,
|
||||
0x0B47, 0x0B4C,
|
||||
0x0B57, 0x0B57,
|
||||
0x0B83, 0x0B83,
|
||||
0x0BBE, 0x0BBF,
|
||||
0x0BC1, 0x0BCC,
|
||||
0x0BD7, 0x0BD7,
|
||||
0x0C01, 0x0C03,
|
||||
0x0C41, 0x0C44,
|
||||
0x0C82, 0x0C83,
|
||||
0x0CBE, 0x0CBE,
|
||||
0x0CC0, 0x0CC4,
|
||||
0x0CC7, 0x0CCB,
|
||||
0x0CD5, 0x0CD6,
|
||||
0x0D02, 0x0D03,
|
||||
0x0D3E, 0x0D40,
|
||||
0x0D46, 0x0D4C,
|
||||
0x0D57, 0x0D57,
|
||||
0x0F7F, 0x0F7F,
|
||||
0x20D0, 0x20E1,
|
||||
0x3099, 0x309A,
|
||||
0xFE20, 0xFE23,
|
||||
0xffff, 0xffff, };
|
||||
|
||||
const boost::uint_least16_t* p = combining_ranges + 1;
|
||||
while(*p < c) p += 2;
|
||||
--p;
|
||||
if((c >= *p) && (c <= *(p+1)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // re_detail
|
||||
} // boost
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE static_mutex.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Declares static_mutex lock type.
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
|
||||
#include <boost/regex/static_mutex.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_WINTHREADS)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
|
||||
#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER)
|
||||
|
||||
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk)
|
||||
: m_mutex(m), m_have_lock(false)
|
||||
{
|
||||
if(lk)
|
||||
lock();
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::~scoped_static_mutex_lock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
unlock();
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::lock()
|
||||
{
|
||||
if(0 == m_have_lock)
|
||||
{
|
||||
pthread_mutex_lock(&(m_mutex.m_mutex));
|
||||
m_have_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::unlock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
{
|
||||
pthread_mutex_unlock(&(m_mutex.m_mutex));
|
||||
m_have_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(BOOST_HAS_WINTHREADS)
|
||||
|
||||
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk)
|
||||
: m_mutex(m), m_have_lock(false)
|
||||
{
|
||||
if(lk)
|
||||
lock();
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::~scoped_static_mutex_lock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
unlock();
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::lock()
|
||||
{
|
||||
if(0 == m_have_lock)
|
||||
{
|
||||
while(0 != InterlockedCompareExchange((LONG*)&(m_mutex.m_mutex), 1, 0))
|
||||
{
|
||||
Sleep(0);
|
||||
}
|
||||
m_have_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::unlock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
{
|
||||
InterlockedExchange((LONG*)&(m_mutex.m_mutex), 0);
|
||||
m_have_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
//
|
||||
// Portable version of a static mutex based on Boost.Thread library:
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
boost::recursive_mutex* static_mutex::m_pmutex = 0;
|
||||
boost::once_flag static_mutex::m_once = BOOST_ONCE_INIT;
|
||||
|
||||
extern "C" void free_static_mutex()
|
||||
{
|
||||
delete static_mutex::m_pmutex;
|
||||
static_mutex::m_pmutex = 0;
|
||||
}
|
||||
|
||||
void static_mutex::init()
|
||||
{
|
||||
m_pmutex = new boost::recursive_mutex();
|
||||
int r = atexit(free_static_mutex);
|
||||
assert(0 == r);
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& , bool lk)
|
||||
: m_plock(0), m_have_lock(false)
|
||||
{
|
||||
if(lk)
|
||||
lock();
|
||||
}
|
||||
|
||||
scoped_static_mutex_lock::~scoped_static_mutex_lock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
unlock();
|
||||
delete m_plock;
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::lock()
|
||||
{
|
||||
if(0 == m_have_lock)
|
||||
{
|
||||
boost::call_once(&static_mutex::init, static_mutex::m_once);
|
||||
if(0 == m_plock)
|
||||
m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, false);
|
||||
m_plock->lock();
|
||||
m_have_lock = true;
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_static_mutex_lock::unlock()
|
||||
{
|
||||
if(m_have_lock)
|
||||
{
|
||||
m_plock->unlock();
|
||||
m_have_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_HAS_THREADS
|
||||
+7
-15
@@ -43,7 +43,6 @@ const wchar_t* wnames[] = {L"REG_NOERROR", L"REG_NOMATCH", L"REG_BADPAT", L"REG_
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic != wmagic_value)
|
||||
{
|
||||
expression->guts = 0;
|
||||
@@ -62,7 +61,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
#endif
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? wregex::extended : wregex::basic;
|
||||
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||
|
||||
// and translate those that are actually set:
|
||||
@@ -82,13 +81,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
if(f & REG_ICASE)
|
||||
flags |= wregex::icase;
|
||||
if(f & REG_ESCAPE_IN_LISTS)
|
||||
flags |= wregex::escape_in_lists;
|
||||
flags &= ~wregex::no_escape_in_lists;
|
||||
if(f & REG_NEWLINE_ALT)
|
||||
flags |= wregex::newline_alt;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
if(f & REG_PERLEX)
|
||||
flags |= wregex::perlex;
|
||||
#endif
|
||||
|
||||
const wchar_t* p2;
|
||||
if(f & REG_PEND)
|
||||
@@ -118,7 +113,6 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
|
||||
BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* e, wchar_t* buf, regsize_t buf_size)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t result = 0;
|
||||
if(code & REG_ITOA)
|
||||
{
|
||||
@@ -162,12 +156,12 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
pt = &static_cast<wregex*>(e->guts)->get_traits();
|
||||
(void)pt; // warning suppression
|
||||
std::string p = pt->error_string(code);
|
||||
std::size_t len = pt->strwiden(static_cast<wchar_t*>(0), 0, p.c_str());
|
||||
if(len < buf_size)
|
||||
if(p.size() < buf_size)
|
||||
{
|
||||
pt->strwiden(buf, buf_size, p.c_str());
|
||||
std::copy(p.begin(), p.end(), buf);
|
||||
buf[p.size()] = 0;
|
||||
}
|
||||
return len + 1;
|
||||
return p.size() + 1;
|
||||
}
|
||||
if(buf_size)
|
||||
*buf = 0;
|
||||
@@ -176,7 +170,6 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW*
|
||||
|
||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, const wchar_t* buf, regsize_t n, regmatch_t* array, int eflags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
bool result = false;
|
||||
match_flag_type flags = match_default | expression->eflags;
|
||||
const wchar_t* end;
|
||||
@@ -216,7 +209,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
if(result)
|
||||
{
|
||||
// extract what matched:
|
||||
unsigned int i;
|
||||
std::size_t i;
|
||||
for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i)
|
||||
{
|
||||
array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf);
|
||||
@@ -235,7 +228,6 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
delete static_cast<wregex*>(expression->guts);
|
||||
|
||||
Reference in new issue
Block a user