forked from boostorg/regex
merged changes in regex5 branch
[SVN r26692]
This commit is contained in:
@ -21,11 +21,33 @@
|
||||
|
||||
#include <climits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/fileiter.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
#endif
|
||||
#include <boost/regex/pattern_except.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::sprintf;
|
||||
using ::fseek;
|
||||
using ::fread;
|
||||
using ::ftell;
|
||||
using ::fopen;
|
||||
using ::fclose;
|
||||
using ::FILE;
|
||||
using ::strcpy;
|
||||
using ::strcpy;
|
||||
using ::strcat;
|
||||
using ::strcmp;
|
||||
using ::strlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
|
||||
@ -47,7 +69,7 @@ namespace boost{
|
||||
// directories are separated with '\\'
|
||||
// and names are insensitive of case
|
||||
|
||||
const char* _fi_sep = "\\";
|
||||
BOOST_REGEX_DECL const char* _fi_sep = "\\";
|
||||
const char* _fi_sep_alt = "/";
|
||||
#define BOOST_REGEX_FI_TRANSLATE(c) std::tolower(c)
|
||||
|
||||
@ -57,7 +79,7 @@ const char* _fi_sep_alt = "/";
|
||||
// directories are separated with '/'
|
||||
// and names are sensitive of case
|
||||
|
||||
const char* _fi_sep = "/";
|
||||
BOOST_REGEX_DECL const char* _fi_sep = "/";
|
||||
const char* _fi_sep_alt = _fi_sep;
|
||||
#define BOOST_REGEX_FI_TRANSLATE(c) c
|
||||
|
||||
@ -67,7 +89,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 );
|
||||
@ -84,7 +105,7 @@ void mapfile::open(const char* file)
|
||||
hmap = 0;
|
||||
hfile = 0;
|
||||
std::runtime_error err("Unable to create file mapping.");
|
||||
boost::throw_exception(err);
|
||||
boost::re_detail::raise_runtime_error(err);
|
||||
}
|
||||
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
|
||||
if(_first == 0)
|
||||
@ -110,7 +131,6 @@ void mapfile::open(const char* file)
|
||||
|
||||
void mapfile::close()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
UnmapViewOfFile((void*)_first);
|
||||
@ -125,7 +145,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 +157,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 +169,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 +182,6 @@ mapfile_iterator mapfile_iterator::operator++ (int)
|
||||
|
||||
mapfile_iterator& mapfile_iterator::operator-- ()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((offset == 0) && file)
|
||||
{
|
||||
--node;
|
||||
@ -180,7 +196,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 +211,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 +218,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 +225,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 +275,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 +288,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 +298,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 +332,6 @@ void mapfile::open(const char* file)
|
||||
|
||||
void mapfile::close()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(hfile != 0)
|
||||
{
|
||||
pointer* p = _first;
|
||||
@ -350,7 +356,6 @@ void mapfile::close()
|
||||
|
||||
file_iterator::file_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -381,7 +386,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 +454,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 +481,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 +498,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 +510,6 @@ file_iterator::~file_iterator()
|
||||
|
||||
file_iterator file_iterator::operator++(int)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
file_iterator temp(*this);
|
||||
next();
|
||||
return temp;
|
||||
@ -518,7 +518,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 +544,6 @@ void file_iterator::next()
|
||||
|
||||
directory_iterator::directory_iterator()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@ -576,7 +574,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 +640,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 +652,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 +679,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 +695,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 +702,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 +740,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 +766,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,12 +807,11 @@ 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);
|
||||
(std::sprintf)(buf, "%s%s", root, name);
|
||||
else
|
||||
std::sprintf(buf, "%s%s%s", root, _fi_sep, name);
|
||||
(std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
|
||||
DIR* d = opendir(buf);
|
||||
if(d)
|
||||
{
|
||||
@ -834,7 +823,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 +838,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 +855,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;
|
||||
|
Reference in New Issue
Block a user