forked from boostorg/regex
Initial commit of v4 of boost.regex on regex-4 branch
[SVN r18128]
This commit is contained in:
@@ -35,8 +35,13 @@
|
||||
#include <cstdio>
|
||||
#include <boost/cregex.hpp>
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_synch.hpp>
|
||||
#include <boost/regex/v3/regex_cstring.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_synch.hpp>
|
||||
#include <boost/regex/v4/regex_cstring.hpp>
|
||||
#endif
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
#include "primary_transform.hpp"
|
||||
@@ -1071,3 +1076,4 @@ std::size_t BOOST_REGEX_CALL c_regex_traits<wchar_t>::strwiden(wchar_t *s1, std:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,11 @@
|
||||
#include <list>
|
||||
#include <cctype>
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_synch.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_synch.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost{
|
||||
@@ -555,3 +559,4 @@ BOOST_REGEX_DECL wchar_t wide_lower_case_map[] = {
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_WSTREAMBUF)
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4786 4702 4127 4244)
|
||||
@@ -347,6 +347,18 @@ cpp_regex_traits<char>::cpp_regex_traits()
|
||||
sort_type = re_detail::find_sort_syntax(this, &(this->sort_delim));
|
||||
}
|
||||
|
||||
void cpp_regex_traits<char>::swap(cpp_regex_traits<char>& that)
|
||||
{
|
||||
std::swap(locale_inst, that.locale_inst); // this one goes first
|
||||
std::swap(pmd, that.pmd);
|
||||
std::swap(psyntax, that.psyntax);
|
||||
std::swap(lower_map, that.lower_map);
|
||||
std::swap(pctype, that.pctype);
|
||||
std::swap(pcollate, that.pcollate);
|
||||
std::swap(sort_type, that.sort_type);
|
||||
std::swap(sort_delim, that.sort_delim);
|
||||
}
|
||||
|
||||
cpp_regex_traits<char>::~cpp_regex_traits()
|
||||
{
|
||||
delete pmd;
|
||||
@@ -464,7 +476,7 @@ cpp_regex_traits<char>::locale_type BOOST_REGEX_CALL cpp_regex_traits<char>::imb
|
||||
return old_l;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_STD_WSTREAMBUF)
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
@@ -870,6 +882,19 @@ std::size_t BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::strwiden(wchar_t *s1, st
|
||||
return ws.size()+1;
|
||||
}
|
||||
|
||||
void cpp_regex_traits<wchar_t>::swap(cpp_regex_traits<wchar_t>& that)
|
||||
{
|
||||
std::swap(locale_inst, that.locale_inst); // this one must go first
|
||||
std::swap(pmd, that.pmd);
|
||||
std::swap(psyntax, that.psyntax);
|
||||
std::swap(lower_map, that.lower_map);
|
||||
std::swap(pctype, that.pctype);
|
||||
std::swap(pcollate, that.pcollate);
|
||||
std::swap(pcdv, that.pcdv);
|
||||
std::swap(sort_type, that.sort_type);
|
||||
std::swap(sort_delim, that.sort_delim);
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_WREGEX
|
||||
|
||||
|
||||
@@ -878,3 +903,4 @@ std::size_t BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::strwiden(wchar_t *s1, st
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
+21
-36
@@ -28,7 +28,13 @@
|
||||
#if !defined(BOOST_NO_STD_STRING)
|
||||
#include <map>
|
||||
#include <list>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/fileiter.hpp>
|
||||
typedef unsigned match_flag_type;
|
||||
#else
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
typedef boost::match_flag_type match_flag_type;
|
||||
#endif
|
||||
#include <cstdio>
|
||||
|
||||
namespace boost{
|
||||
@@ -79,11 +85,10 @@ public:
|
||||
regex e;
|
||||
cmatch m;
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
match_results<mapfile::iterator, regex::allocator_type> fm;
|
||||
match_results<mapfile::iterator> fm;
|
||||
#endif
|
||||
type t;
|
||||
const char* pbase;
|
||||
unsigned line;
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
mapfile::iterator fbase;
|
||||
#endif
|
||||
@@ -95,7 +100,7 @@ public:
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
fm(),
|
||||
#endif
|
||||
t(type_copy), pbase(0), line(0),
|
||||
t(type_copy), pbase(0),
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
fbase(),
|
||||
#endif
|
||||
@@ -114,7 +119,6 @@ void RegExData::update()
|
||||
if(m[i].matched) strings[i] = std::string(m[i].first, m[i].second);
|
||||
positions[i] = m[i].matched ? m[i].first - pbase : -1;
|
||||
}
|
||||
line = m.line();
|
||||
}
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
else
|
||||
@@ -124,7 +128,6 @@ void RegExData::update()
|
||||
if(fm[i].matched) strings[i] = to_string(fm[i].first, fm[i].second);
|
||||
positions[i] = fm[i].matched ? fm[i].first - fbase : -1;
|
||||
}
|
||||
line = fm.line();
|
||||
}
|
||||
#endif
|
||||
t = type_copy;
|
||||
@@ -135,7 +138,7 @@ void RegExData::clean()
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
fbase = mapfile::iterator();
|
||||
fm = match_results<mapfile::iterator, regex::allocator_type>();
|
||||
fm = match_results<mapfile::iterator>();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -209,7 +212,7 @@ std::string RegEx::Expression()const
|
||||
//
|
||||
// now matching operators:
|
||||
//
|
||||
bool RegEx::Match(const char* p, unsigned int flags)
|
||||
bool RegEx::Match(const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
@@ -225,7 +228,7 @@ bool RegEx::Match(const char* p, unsigned int flags)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RegEx::Search(const char* p, unsigned int flags)
|
||||
bool RegEx::Search(const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
@@ -253,7 +256,7 @@ struct pred1
|
||||
}
|
||||
};
|
||||
}
|
||||
unsigned int RegEx::Grep(GrepCallback cb, const char* p, unsigned int flags)
|
||||
unsigned int RegEx::Grep(GrepCallback cb, const char* p, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
pdata->t = re_detail::RegExData::type_pc;
|
||||
@@ -283,7 +286,7 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
unsigned int RegEx::Grep(std::vector<std::string>& v, const char* p, unsigned int flags)
|
||||
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;
|
||||
@@ -313,7 +316,7 @@ private:
|
||||
pred3& operator=(const pred3&);
|
||||
};
|
||||
}
|
||||
unsigned int RegEx::Grep(std::vector<std::size_t>& v, const char* p, unsigned int flags)
|
||||
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;
|
||||
@@ -335,7 +338,7 @@ struct pred4
|
||||
const char* file;
|
||||
bool ok;
|
||||
pred4(GrepFileCallback c, RegEx* i, const char* f) : cb(c), pe(i), file(f), ok(true) {}
|
||||
bool operator()(const match_results<mapfile::iterator, regex::allocator_type>& m)
|
||||
bool operator()(const match_results<mapfile::iterator>& m)
|
||||
{
|
||||
pe->pdata->t = RegExData::type_pf;
|
||||
pe->pdata->fm = m;
|
||||
@@ -391,7 +394,7 @@ void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, unsigned int flags)
|
||||
unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int result = 0;
|
||||
@@ -419,7 +422,7 @@ unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recur
|
||||
}
|
||||
|
||||
|
||||
unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, unsigned int flags)
|
||||
unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, match_flag_type flags)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
unsigned int result = 0;
|
||||
@@ -451,7 +454,7 @@ unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recu
|
||||
#endif
|
||||
|
||||
std::string RegEx::Merge(const std::string& in, const std::string& fmt,
|
||||
bool copy, unsigned int flags)
|
||||
bool copy, match_flag_type flags)
|
||||
{
|
||||
std::string result;
|
||||
re_detail::string_out_iterator<std::string> i(result);
|
||||
@@ -461,7 +464,7 @@ std::string RegEx::Merge(const std::string& in, const std::string& fmt,
|
||||
}
|
||||
|
||||
std::string RegEx::Merge(const char* in, const char* fmt,
|
||||
bool copy, unsigned int flags)
|
||||
bool copy, match_flag_type flags)
|
||||
{
|
||||
std::string result;
|
||||
if(!copy) flags |= format_no_copy;
|
||||
@@ -472,7 +475,7 @@ std::string RegEx::Merge(const char* in, const char* fmt,
|
||||
|
||||
std::size_t RegEx::Split(std::vector<std::string>& v,
|
||||
std::string& s,
|
||||
unsigned flags,
|
||||
match_flag_type flags,
|
||||
unsigned max_count)
|
||||
{
|
||||
return regex_split(std::back_inserter(v), s, pdata->e, flags, max_count);
|
||||
@@ -505,25 +508,6 @@ std::size_t RegEx::Position(int i)const
|
||||
return RegEx::npos;
|
||||
}
|
||||
|
||||
unsigned int RegEx::Line()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
switch(pdata->t)
|
||||
{
|
||||
case re_detail::RegExData::type_pc:
|
||||
return pdata->m[0].matched ? pdata->m.line() : RegEx::npos;
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
case re_detail::RegExData::type_pf:
|
||||
return pdata->fm[0].matched ? pdata->fm.line() : RegEx::npos;
|
||||
#endif
|
||||
case re_detail::RegExData::type_copy:
|
||||
{
|
||||
return pdata->line;
|
||||
}
|
||||
}
|
||||
return RegEx::npos;
|
||||
}
|
||||
|
||||
unsigned int RegEx::Marks()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
@@ -656,3 +640,4 @@ basic_string<char>::replace<const char*>(char* f1, char* f2, const char* i1, con
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,11 @@
|
||||
|
||||
#include <climits>
|
||||
#include <stdexcept>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/fileiter.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
|
||||
@@ -901,3 +905,4 @@ bool _fi_FindClose(_fi_find_handle dat)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-2
@@ -59,7 +59,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regbase::extended : regbase::basic;
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : 0;
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||
// and translate those that are actually set:
|
||||
|
||||
if(f & REG_NOCOLLATE)
|
||||
@@ -76,6 +76,10 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
flags |= regbase::escape_in_lists;
|
||||
if(f & REG_NEWLINE_ALT)
|
||||
flags |= regbase::newline_alt;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
if(f & REG_PERLEX)
|
||||
flags |= regbase::perlex;
|
||||
#endif
|
||||
|
||||
const char* p2;
|
||||
if(f & REG_PEND)
|
||||
@@ -165,7 +169,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
bool result = false;
|
||||
boost::uint_fast32_t flags = match_default | expression->eflags;
|
||||
match_flag_type flags = match_default | expression->eflags;
|
||||
const char* end;
|
||||
const char* start;
|
||||
cmatch m;
|
||||
|
||||
+81
-1
@@ -23,12 +23,16 @@
|
||||
|
||||
#define BOOST_REGEX_SOURCE
|
||||
|
||||
#include <new>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
|
||||
//
|
||||
// fix: these are declared out of line here to ensure
|
||||
// that dll builds contain the Virtual table for these
|
||||
@@ -43,6 +47,81 @@ regbase::regbase()
|
||||
regbase::regbase(const regbase& b)
|
||||
: _flags(b._flags){}
|
||||
|
||||
|
||||
namespace re_detail{
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||
{
|
||||
#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
_resetstkoflw();
|
||||
#else
|
||||
//
|
||||
// We need to locate the current page being used by the stack,
|
||||
// move to the page below it and then deallocate and protect
|
||||
// that page. Note that ideally we would protect only the lowest
|
||||
// stack page that has been allocated: in practice there
|
||||
// seems to be no easy way to locate this page, in any case as
|
||||
// long as the next page is protected, then Windows will figure
|
||||
// the rest out for us...
|
||||
//
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
MEMORY_BASIC_INFORMATION mi;
|
||||
DWORD previous_protection_status;
|
||||
//
|
||||
// this is an address in our stack space:
|
||||
//
|
||||
LPBYTE page = (LPBYTE)&page;
|
||||
//
|
||||
// Get the current memory page in use:
|
||||
//
|
||||
VirtualQuery(page, &mi, sizeof(mi));
|
||||
//
|
||||
// Go to the page one below this:
|
||||
//
|
||||
page = (LPBYTE)(mi.BaseAddress)-si.dwPageSize;
|
||||
//
|
||||
// Free and protect everything from the start of the
|
||||
// allocation range, to the end of the page below the
|
||||
// one in use:
|
||||
//
|
||||
if (!VirtualFree(mi.AllocationBase, (LPBYTE)page - (LPBYTE)mi.AllocationBase, MEM_DECOMMIT)
|
||||
|| !VirtualProtect(page, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &previous_protection_status))
|
||||
{
|
||||
throw std::bad_exception();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#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)
|
||||
|
||||
BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block()
|
||||
{
|
||||
return ::operator new(BOOST_REGEX_BLOCKSIZE);
|
||||
}
|
||||
|
||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL release_mem_block(void* p)
|
||||
{
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
mem_block_cache block_cache = { 0, };
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace re_detail
|
||||
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(BOOST_RE_USE_VCL) && defined(BOOST_REGEX_BUILD_DLL)
|
||||
@@ -58,3 +137,4 @@ int WINAPI DllEntryPoint(HINSTANCE , unsigned long , void*)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@
|
||||
#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
|
||||
@@ -217,3 +221,4 @@ debug_guard::~debug_guard()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,12 @@
|
||||
|
||||
#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{
|
||||
@@ -68,3 +73,5 @@ BOOST_REGEX_DECL unsigned int re_lock_count = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,13 @@
|
||||
#include <boost/regex/regex_traits.hpp>
|
||||
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
|
||||
#include <boost/cregex.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/regex_synch.hpp>
|
||||
#include <boost/regex/v3/regex_cstring.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/regex_synch.hpp>
|
||||
#include <boost/regex/v4/regex_cstring.hpp>
|
||||
#endif
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
|
||||
@@ -1102,3 +1107,4 @@ unsigned short w32_regex_traits<wchar_t>::wide_unicode_classes[] = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regbase::extended : regbase::basic;
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : 0;
|
||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||
|
||||
// and translate those that are actually set:
|
||||
if(f & REG_NOCOLLATE)
|
||||
@@ -84,6 +84,10 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
flags |= regbase::escape_in_lists;
|
||||
if(f & REG_NEWLINE_ALT)
|
||||
flags |= regbase::newline_alt;
|
||||
#ifndef BOOST_REGEX_V3
|
||||
if(f & REG_PERLEX)
|
||||
flags |= regbase::perlex;
|
||||
#endif
|
||||
|
||||
const wchar_t* p2;
|
||||
if(f & REG_PEND)
|
||||
@@ -173,7 +177,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
bool result = false;
|
||||
boost::uint_fast32_t flags = match_default | expression->eflags;
|
||||
match_flag_type flags = match_default | expression->eflags;
|
||||
const wchar_t* end;
|
||||
const wchar_t* start;
|
||||
wcmatch m;
|
||||
|
||||
Reference in New Issue
Block a user