Merged regex-4 branch.

[SVN r18430]
This commit is contained in:
John Maddock
2003-05-17 11:45:48 +00:00
parent a81a1ea30f
commit f0f32bdda1
154 changed files with 32893 additions and 432 deletions

View File

@ -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:

View File

@ -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

View File

@ -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)
@ -254,8 +254,9 @@ message_data<char>::message_data(const std::locale& l, const std::string& regex_
// STLport users as well (gcc3.1+STLport5), so enable the
// workaround for all STLport users...
//
#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
#if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && !defined(BOOST_MSVC)
using namespace std;
using stlport::isspace;
# define BOOST_REGEX_STD
#else
# define BOOST_REGEX_STD std::
@ -347,6 +348,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 +477,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 +883,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 +904,4 @@ std::size_t BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::strwiden(wchar_t *s1, st
#endif

View File

@ -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
}
@ -190,7 +193,7 @@ RegEx& RegEx::operator=(const char* p)
unsigned int RegEx::SetExpression(const char* p, bool icase)
{
BOOST_RE_GUARD_STACK
boost::uint_fast32_t f = icase ? regbase::normal | regbase::use_except | regbase::icase : regbase::normal | regbase::use_except;
boost::uint_fast32_t f = icase ? regex::normal | regex::use_except | regex::icase : regex::normal | regex::use_except;
return pdata->e.set_expression(p, f);
}
@ -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,28 +454,28 @@ 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);
if(!copy) flags |= format_no_copy;
regex_merge(i, in.begin(), in.end(), pdata->e, fmt.c_str(), flags);
regex_replace(i, in.begin(), in.end(), pdata->e, fmt.c_str(), flags);
return result;
}
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;
re_detail::string_out_iterator<std::string> i(result);
regex_merge(i, in, in + std::strlen(in), pdata->e, fmt, flags);
regex_replace(i, in, in + std::strlen(in), pdata->e, fmt, flags);
return result;
}
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

View File

@ -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)

View File

@ -58,24 +58,31 @@ 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) ? regbase::extended : regbase::basic;
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : 0;
boost::uint_fast32_t flags = (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:
if(f & REG_NOCOLLATE)
flags |= regbase::nocollate;
{
flags |= regex::nocollate;
flags &= ~regex::collate;
}
if(f & REG_NOSUB)
expression->eflags |= match_any;
if(f & REG_NOSPEC)
flags |= regbase::literal;
flags |= regex::literal;
if(f & REG_ICASE)
flags |= regbase::icase;
flags |= regex::icase;
if(f & REG_ESCAPE_IN_LISTS)
flags |= regbase::escape_in_lists;
flags |= regex::escape_in_lists;
if(f & REG_NEWLINE_ALT)
flags |= regbase::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)
@ -165,7 +172,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;

View File

@ -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,71 @@ 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)
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 +127,4 @@ int WINAPI DllEntryPoint(HINSTANCE , unsigned long , void*)

View File

@ -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()

View File

@ -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;

View File

@ -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[] = {

View File

@ -66,24 +66,31 @@ 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) ? regbase::extended : regbase::basic;
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : 0;
boost::uint_fast32_t flags = (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:
if(f & REG_NOCOLLATE)
flags |= regbase::nocollate;
{
flags |= wregex::nocollate;
flags &= ~wregex::collate;
}
if(f & REG_NOSUB)
expression->eflags |= match_any;
if(f & REG_NOSPEC)
flags |= regbase::literal;
flags |= wregex::literal;
if(f & REG_ICASE)
flags |= regbase::icase;
flags |= wregex::icase;
if(f & REG_ESCAPE_IN_LISTS)
flags |= regbase::escape_in_lists;
flags |= wregex::escape_in_lists;
if(f & REG_NEWLINE_ALT)
flags |= regbase::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)
@ -173,7 +180,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;