forked from boostorg/regex
Added support for compilers with no exception handling support.
[SVN r12758]
This commit is contained in:
@ -242,6 +242,7 @@ public:
|
||||
unsigned int SetExpression(const char* p, bool icase = false);
|
||||
unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); }
|
||||
std::string Expression()const;
|
||||
unsigned int error_code()const;
|
||||
//
|
||||
// now matching operators:
|
||||
//
|
||||
|
@ -794,7 +794,10 @@ int do_toi(iterator i, iterator j, char c, int radix)
|
||||
std::string s(i, j);
|
||||
char* p;
|
||||
int result = std::strtol(s.c_str(), &p, radix);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(*p)throw bad_pattern("Bad sub-expression");
|
||||
#endif
|
||||
BOOST_REGEX_NOEH_ASSERT(0 == *p)
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -819,7 +822,10 @@ sub_match<iterator>::operator int()const
|
||||
{
|
||||
iterator i = first;
|
||||
iterator j = second;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(i == j)throw bad_pattern("Bad sub-expression");
|
||||
#endif
|
||||
BOOST_REGEX_NOEH_ASSERT(i != j)
|
||||
int neg = 1;
|
||||
if((i != j) && (*i == '-'))
|
||||
{
|
||||
@ -827,7 +833,10 @@ sub_match<iterator>::operator int()const
|
||||
++i;
|
||||
}
|
||||
neg *= re_detail::do_toi(i, j, *i);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(i != j)throw bad_pattern("Bad sub-expression");
|
||||
#endif
|
||||
BOOST_REGEX_NOEH_ASSERT(i == j)
|
||||
return neg;
|
||||
}
|
||||
template <class iterator>
|
||||
@ -835,8 +844,11 @@ sub_match<iterator>::operator unsigned int()const
|
||||
{
|
||||
iterator i = first;
|
||||
iterator j = second;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(i == j)
|
||||
throw bad_pattern("Bad sub-expression");
|
||||
#endif
|
||||
BOOST_REGEX_NOEH_ASSERT(i != j)
|
||||
return re_detail::do_toi(i, j, *first);
|
||||
}
|
||||
#endif
|
||||
@ -1063,15 +1075,20 @@ template <class iterator, class Allocator>
|
||||
match_results_base<iterator, Allocator>::match_results_base(const Allocator& a)
|
||||
{
|
||||
ref = (c_reference*)c_alloc(a).allocate(sizeof(sub_match<iterator>) + sizeof(c_reference));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
new (ref) c_reference(a);
|
||||
ref->cmatches = 1;
|
||||
ref->count = 1;
|
||||
// construct the sub_match<iterator>:
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
new ((sub_match<iterator>*)(ref+1)) sub_match<iterator>();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1084,6 +1101,7 @@ match_results_base<iterator, Allocator>::match_results_base(const Allocator& a)
|
||||
c_alloc(a).deallocate((char*)(void*)ref, sizeof(sub_match<iterator>) + sizeof(c_reference));
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class iterator, class Allocator>
|
||||
@ -1148,22 +1166,27 @@ void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_size(size_typ
|
||||
if(ref->cmatches != n)
|
||||
{
|
||||
c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * n + sizeof(c_reference));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
new (newref) c_reference(*ref);
|
||||
newref->count = 1;
|
||||
newref->cmatches = n;
|
||||
sub_match<iterator>* p1, *p2;
|
||||
p1 = (sub_match<iterator>*)(newref+1);
|
||||
p2 = p1 + newref->cmatches;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
while(p1 != p2)
|
||||
{
|
||||
new (p1) sub_match<iterator>();
|
||||
++p1;
|
||||
}
|
||||
m_free();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1176,13 +1199,16 @@ void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_size(size_typ
|
||||
::boost::re_detail::pointer_destroy(ref);
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
ref = newref;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * n + sizeof(c_reference));
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1192,20 +1218,25 @@ void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_size(size_typ
|
||||
if(ref->cmatches != n)
|
||||
{
|
||||
c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * n + sizeof(c_reference));;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
new (newref) c_reference(*ref);
|
||||
newref->count = 1;
|
||||
newref->cmatches = n;
|
||||
sub_match<iterator>* p1 = (sub_match<iterator>*)(newref+1);
|
||||
sub_match<iterator>* p2 = p1 + newref->cmatches;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
while(p1 != p2)
|
||||
{
|
||||
new (p1) sub_match<iterator>(j);
|
||||
++p1;
|
||||
}
|
||||
m_free();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1218,13 +1249,16 @@ void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_size(size_typ
|
||||
::boost::re_detail::pointer_destroy(ref);
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
ref = newref;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * n + sizeof(c_reference));
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1298,19 +1332,24 @@ void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::cow()
|
||||
if(ref->count > 1)
|
||||
{
|
||||
c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * ref->cmatches + sizeof(c_reference));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
new (newref) c_reference(*ref);
|
||||
newref->count = 1;
|
||||
sub_match<iterator>* p1 = (sub_match<iterator>*)(newref+1);
|
||||
sub_match<iterator>* p2 = p1 + newref->cmatches;
|
||||
sub_match<iterator>* p3 = (sub_match<iterator>*)(ref+1);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
while(p1 != p2)
|
||||
{
|
||||
new (p1) sub_match<iterator>(*p3);
|
||||
++p1;
|
||||
++p3;
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1323,14 +1362,17 @@ void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::cow()
|
||||
::boost::re_detail::pointer_destroy(ref);
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
--(ref->count);
|
||||
ref = newref;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * ref->cmatches + sizeof(c_reference));
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1418,19 +1460,24 @@ match_results<iterator, Allocator>::match_results(const match_results<iterator,
|
||||
reinterpret_cast<typename re_detail::match_results_base<iterator, Allocator>::c_reference *>
|
||||
(m.ref->allocate(sizeof(sub_match<iterator>) * m.ref->cmatches +
|
||||
sizeof(typename re_detail::match_results_base<iterator, Allocator>::c_reference)));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
new (this->ref) typename re_detail::match_results_base<iterator, Allocator>::c_reference(*m.ref);
|
||||
this->ref->count = 1;
|
||||
sub_match<iterator>* p1 = (sub_match<iterator>*)(this->ref+1);
|
||||
sub_match<iterator>* p2 = p1 + this->ref->cmatches;
|
||||
sub_match<iterator>* p3 = (sub_match<iterator>*)(m.ref+1);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
while(p1 != p2)
|
||||
{
|
||||
new (p1) sub_match<iterator>(*p3);
|
||||
++p1;
|
||||
++p3;
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1449,6 +1496,7 @@ match_results<iterator, Allocator>::match_results(const match_results<iterator,
|
||||
m.ref->deallocate((char*)(void*)this->ref, sizeof(sub_match<iterator>) * m.ref->cmatches + sizeof(typename re_detail::match_results_base<iterator, Allocator>::c_reference));
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class iterator, class Allocator>
|
||||
|
@ -273,6 +273,35 @@ using std::distance;
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Error Handling for exception free compilers:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
//
|
||||
// If there are no exceptions then we must report critical-errors
|
||||
// the only way we know how; by terminating.
|
||||
//
|
||||
#ifdef __BORLANDC__
|
||||
// <cstdio> seems not to make stderr usable with Borland:
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
# define BOOST_REGEX_NOEH_ASSERT(x)\
|
||||
if(0 == (x))\
|
||||
{\
|
||||
std::fprintf(stderr, "Error: critical regex++ failure in \"%s\"", #x);\
|
||||
std::abort();\
|
||||
}
|
||||
#else
|
||||
//
|
||||
// With exceptions then error handling is taken care of and
|
||||
// there is no need for these checks:
|
||||
//
|
||||
# define BOOST_REGEX_NOEH_ASSERT(x)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Debugging / tracing support:
|
||||
@ -516,6 +545,10 @@ namespace std{
|
||||
using ::fopen;
|
||||
using ::fclose;
|
||||
using ::FILE;
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
using ::fprintf;
|
||||
using ::abort;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1167,8 +1167,10 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_apply(re_d
|
||||
register re_detail::re_syntax_base* ptr = b;
|
||||
bool* pb = 0;
|
||||
b_alloc a(data.allocator());
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
pb = a.allocate(cbraces);
|
||||
for(unsigned i = 0; i < cbraces; ++i)
|
||||
pb[i] = false;
|
||||
@ -1232,6 +1234,7 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_apply(re_d
|
||||
}
|
||||
a.deallocate(pb, cbraces);
|
||||
pb = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1239,6 +1242,7 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_apply(re_d
|
||||
a.deallocate(pb, cbraces);
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -2053,10 +2057,12 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fail(unsigned in
|
||||
if(err)
|
||||
{
|
||||
_flags |= regbase::failbit;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(_flags & regbase::use_except)
|
||||
{
|
||||
throw bad_expression(traits_inst.error_string(err));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
_flags &= ~regbase::failbit;
|
||||
|
@ -199,14 +199,19 @@ void BOOST_REGEX_CALL re_init_classes()
|
||||
if(classes_count == 0)
|
||||
{
|
||||
re_cls_name = new std::string("xxxxxxxx");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
pclasses = new std::string[re_classes_max];
|
||||
BOOST_REGEX_NOEH_ASSERT(pclasses)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete re_cls_name;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
++classes_count;
|
||||
}
|
||||
@ -243,14 +248,19 @@ void BOOST_REGEX_CALL re_init_collate()
|
||||
if(collate_count == 0)
|
||||
{
|
||||
re_coll_name = new std::string("xxxxxxxx");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
pcoll_names = new std::list<collate_name_t>();
|
||||
BOOST_REGEX_NOEH_ASSERT(pcoll_names)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete re_coll_name;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
++collate_count;
|
||||
}
|
||||
@ -345,11 +355,15 @@ void BOOST_REGEX_CALL re_message_update()
|
||||
if(*boost::re_detail::c_traits_base::get_catalogue())
|
||||
{
|
||||
message_cat = catopen(boost::re_detail::c_traits_base::get_catalogue(), 0);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(message_cat == (nl_catd)-1)
|
||||
{
|
||||
std::string m("Unable to open message catalog: ");
|
||||
throw std::runtime_error(m + boost::re_detail::c_traits_base::get_catalogue());
|
||||
}
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(message_cat != (nl_catd)-1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
for(int i = 0; i < boost::REG_E_UNKNOWN; ++i)
|
||||
@ -592,14 +606,19 @@ void BOOST_REGEX_CALL c_regex_traits<char>::init()
|
||||
if(entry_count == 0)
|
||||
{
|
||||
ctype_name = new std::string("xxxxxxxxxxxxxxxx");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
collate_name = new std::string("xxxxxxxxxxxxxxxx");
|
||||
BOOST_REGEX_NOEH_ASSERT(collate_name)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete ctype_name;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
re_message_init();
|
||||
re_init_classes();
|
||||
@ -763,14 +782,19 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::init()
|
||||
if(nlsw_count == 0)
|
||||
{
|
||||
wlocale_name = new std::string("xxxxxxxxxxxxxxxx");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
syntax = new std::list<syntax_map_t>();
|
||||
BOOST_REGEX_NOEH_ASSERT(syntax)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete wlocale_name;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
++nlsw_count;
|
||||
}
|
||||
|
@ -197,11 +197,15 @@ message_data<char>::message_data(const std::locale& l, const std::string& regex_
|
||||
{
|
||||
pm = &BOOST_USE_FACET(std::messages<char>, l);
|
||||
cat = pm->open(regex_message_catalogue, l);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(cat < 0)
|
||||
{
|
||||
std::string m("Unable to open message catalog: ");
|
||||
throw std::runtime_error(m + regex_message_catalogue);
|
||||
}
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(cat >= 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
std::memset(syntax_map, cpp_regex_traits<char>::syntax_char, 256);
|
||||
@ -296,14 +300,19 @@ cpp_regex_traits<char>::cpp_regex_traits()
|
||||
{
|
||||
pmd = new re_detail::message_data<char>(locale_inst, regex_message_cat);
|
||||
psyntax = pmd->syntax_map;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
lower_map = new char[char_set_size];
|
||||
BOOST_REGEX_NOEH_ASSERT(lower_map)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete pmd;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
for(unsigned int i = 0; i < char_set_size; ++i)
|
||||
lower_map[i] = static_cast<char>(i);
|
||||
pctype = &BOOST_USE_FACET(std::ctype<char>, locale_inst);
|
||||
@ -565,11 +574,15 @@ message_data<wchar_t>::message_data(const std::locale& l, const std::string& reg
|
||||
if(regex_message_catalogue.size())
|
||||
{
|
||||
cat = msgs.open(regex_message_catalogue, l);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(cat < 0)
|
||||
{
|
||||
std::string m("Unable to open message catalog: ");
|
||||
throw std::runtime_error(m + regex_message_catalogue);
|
||||
}
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(cat >= 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
scoped_array<char> a;
|
||||
@ -770,14 +783,19 @@ cpp_regex_traits<wchar_t>::cpp_regex_traits()
|
||||
{
|
||||
pmd = new re_detail::message_data<wchar_t>(locale_inst, std::string(regex_message_cat));
|
||||
psyntax = pmd->syntax_;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
lower_map = new wchar_t[char_set_size];
|
||||
BOOST_REGEX_NOEH_ASSERT(lower_map)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete pmd;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
for(unsigned int i = 0; i < char_set_size; ++i)
|
||||
lower_map[i] = static_cast<wchar_t>(i);
|
||||
pctype = &BOOST_USE_FACET(std::ctype<wchar_t>, locale_inst);
|
||||
|
@ -178,6 +178,12 @@ unsigned int RegEx::SetExpression(const char* p, bool icase)
|
||||
return pdata->e.set_expression(p, f);
|
||||
}
|
||||
|
||||
unsigned int RegEx::error_code()const
|
||||
{
|
||||
return pdata->e.error_code();
|
||||
}
|
||||
|
||||
|
||||
std::string RegEx::Expression()const
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
|
@ -81,7 +81,11 @@ void mapfile::open(const char* file)
|
||||
CloseHandle(hfile);
|
||||
hmap = 0;
|
||||
hfile = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw std::runtime_error("Unable to create file mapping.");
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(hmap != INVALID_HANDLE_VALUE);
|
||||
#endif
|
||||
}
|
||||
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
|
||||
if(_first == 0)
|
||||
@ -90,14 +94,22 @@ void mapfile::open(const char* file)
|
||||
CloseHandle(hfile);
|
||||
hmap = 0;
|
||||
hfile = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw std::runtime_error("Unable to create file mapping.");
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(_first != 0);
|
||||
#endif
|
||||
}
|
||||
_last = _first + GetFileSize(hfile, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
hfile = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw std::runtime_error("Unable to open file.");
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(hfile != INVALID_HANDLE_VALUE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,7 +297,9 @@ void mapfile::open(const char* file)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
hfile = std::fopen(file, "rb");
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
if(hfile != 0)
|
||||
{
|
||||
_size = get_file_length(hfile);
|
||||
@ -306,10 +320,16 @@ void mapfile::open(const char* file)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw std::runtime_error("Unable to open file.");
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(hfile != 0);
|
||||
#endif
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}catch(...)
|
||||
{ close(); throw; }
|
||||
#endif
|
||||
}
|
||||
|
||||
void mapfile::close()
|
||||
@ -342,15 +362,21 @@ file_iterator::file_iterator()
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
_root = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
||||
_path = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
||||
ptr = _path;
|
||||
*_path = 0;
|
||||
*_root = 0;
|
||||
ref = new file_iterator_ref();
|
||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
||||
ref->hf = _fi_invalid_handle;
|
||||
ref->count = 1;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -359,6 +385,7 @@ file_iterator::file_iterator()
|
||||
delete ref;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
file_iterator::file_iterator(const char* wild)
|
||||
@ -366,9 +393,13 @@ file_iterator::file_iterator(const char* wild)
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
_root = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
||||
_path = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
||||
std::strcpy(_root, wild);
|
||||
ptr = _root;
|
||||
while(*ptr)++ptr;
|
||||
@ -399,6 +430,7 @@ file_iterator::file_iterator(const char* wild)
|
||||
#endif
|
||||
|
||||
ref = new file_iterator_ref();
|
||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
||||
ref->hf = FindFirstFileA(wild, &(ref->_data));
|
||||
ref->count = 1;
|
||||
|
||||
@ -413,6 +445,7 @@ file_iterator::file_iterator(const char* wild)
|
||||
if(ref->_data.dwFileAttributes & _fi_dir)
|
||||
next();
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -421,6 +454,7 @@ file_iterator::file_iterator(const char* wild)
|
||||
delete ref;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
file_iterator::file_iterator(const file_iterator& other)
|
||||
@ -428,13 +462,18 @@ file_iterator::file_iterator(const file_iterator& other)
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
_root = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
||||
_path = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
||||
std::strcpy(_root, other._root);
|
||||
std::strcpy(_path, other._path);
|
||||
ptr = _path + (other.ptr - other._path);
|
||||
ref = other.ref;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -442,6 +481,7 @@ file_iterator::file_iterator(const file_iterator& other)
|
||||
delete[] _path;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
++(ref->count);
|
||||
}
|
||||
|
||||
@ -517,15 +557,21 @@ directory_iterator::directory_iterator()
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
_root = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
||||
_path = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
||||
ptr = _path;
|
||||
*_path = 0;
|
||||
*_root = 0;
|
||||
ref = new file_iterator_ref();
|
||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
||||
ref->hf = _fi_invalid_handle;
|
||||
ref->count = 1;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -534,6 +580,7 @@ directory_iterator::directory_iterator()
|
||||
delete ref;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
directory_iterator::directory_iterator(const char* wild)
|
||||
@ -541,9 +588,13 @@ directory_iterator::directory_iterator(const char* wild)
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
_root = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
||||
_path = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
||||
std::strcpy(_root, wild);
|
||||
ptr = _root;
|
||||
while(*ptr)++ptr;
|
||||
@ -573,6 +624,7 @@ directory_iterator::directory_iterator(const char* wild)
|
||||
}
|
||||
#endif
|
||||
ref = new file_iterator_ref();
|
||||
BOOST_REGEX_NOEH_ASSERT(ref)
|
||||
ref->count = 1;
|
||||
ref->hf = FindFirstFileA(wild, &(ref->_data));
|
||||
if(ref->hf == _fi_invalid_handle)
|
||||
@ -586,6 +638,7 @@ directory_iterator::directory_iterator(const char* wild)
|
||||
if(((ref->_data.dwFileAttributes & _fi_dir) == 0) || (std::strcmp(ref->_data.cFileName, ".") == 0) || (std::strcmp(ref->_data.cFileName, "..") == 0))
|
||||
next();
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -594,6 +647,7 @@ directory_iterator::directory_iterator(const char* wild)
|
||||
delete ref;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
directory_iterator::~directory_iterator()
|
||||
@ -614,13 +668,18 @@ directory_iterator::directory_iterator(const directory_iterator& other)
|
||||
BOOST_RE_GUARD_STACK
|
||||
_root = _path = 0;
|
||||
ref = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
_root = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_root)
|
||||
_path = new char[MAX_PATH];
|
||||
BOOST_REGEX_NOEH_ASSERT(_path)
|
||||
std::strcpy(_root, other._root);
|
||||
std::strcpy(_path, other._path);
|
||||
ptr = _path + (other.ptr - other._path);
|
||||
ref = other.ref;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -628,6 +687,7 @@ directory_iterator::directory_iterator(const directory_iterator& other)
|
||||
delete[] _path;
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
++(ref->count);
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
if(expression->re_magic != magic_value)
|
||||
{
|
||||
expression->guts = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
expression->guts = new regex();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
return REG_ESPACE;
|
||||
}
|
||||
#else
|
||||
if(0 == expression->guts)
|
||||
return REG_E_MEMORY;
|
||||
#endif
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regbase::extended : regbase::basic;
|
||||
@ -77,15 +84,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
|
||||
int result;
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
expression->re_magic = magic_value;
|
||||
static_cast<regex*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<regex*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<regex*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
result = REG_E_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
if(result)
|
||||
regfreeA(expression);
|
||||
return result;
|
||||
@ -174,17 +185,21 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
end = buf + std::strlen(buf);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
if(expression->re_magic == magic_value)
|
||||
{
|
||||
result = regex_search(start, end, m, *static_cast<regex*>(expression->guts), flags);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
return REG_E_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(result)
|
||||
{
|
||||
|
@ -236,11 +236,15 @@ void BOOST_REGEX_CALL w32_traits_base::do_init()
|
||||
if(*regex_message_catalogue)
|
||||
{
|
||||
hresmod = LoadLibraryA(regex_message_catalogue);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(hresmod == NULL)
|
||||
{
|
||||
std::string s("Unable to open dll: ");
|
||||
throw std::runtime_error(s + regex_message_catalogue);
|
||||
}
|
||||
#else
|
||||
BOOST_REGEX_NOEH_ASSERT(hresmod != NULL);
|
||||
#endif
|
||||
}
|
||||
unsigned int i;
|
||||
for(i = 0; i < REG_E_UNKNOWN; ++i)
|
||||
|
@ -51,12 +51,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
if(expression->re_magic != wmagic_value)
|
||||
{
|
||||
expression->guts = 0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
expression->guts = new wregex();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
return REG_ESPACE;
|
||||
}
|
||||
#else
|
||||
if(0 == expression->guts)
|
||||
return REG_E_MEMORY;
|
||||
#endif
|
||||
}
|
||||
// set default flags:
|
||||
boost::uint_fast32_t flags = (f & REG_EXTENDED) ? regbase::extended : regbase::basic;
|
||||
@ -85,15 +92,19 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
|
||||
int result;
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
expression->re_magic = wmagic_value;
|
||||
static_cast<wregex*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<wregex*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<wregex*>(expression->guts)->error_code();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
result = REG_E_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
if(result)
|
||||
regfreeW(expression);
|
||||
return result;
|
||||
@ -182,18 +193,21 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
end = buf + std::wcslen(buf);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try{
|
||||
#endif
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
result = regex_search(start, end, m, *static_cast<wregex*>(expression->guts), flags);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
} catch(...)
|
||||
{
|
||||
return REG_E_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif
|
||||
if(result)
|
||||
{
|
||||
// extract what matched:
|
||||
|
@ -58,11 +58,14 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
|
||||
#ifndef __GNUC__
|
||||
bool thrown = false;
|
||||
// try set_expression form first:
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
A a;
|
||||
reg_expression<C, T, A> e(a);
|
||||
e.set_expression(expression.c_str(), flags[2] | regbase::use_except);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(const boost::bad_expression&)
|
||||
{
|
||||
@ -74,14 +77,18 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
|
||||
begin_error();
|
||||
cout << "Error: expected exception not thrown" << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// now try constructor form:
|
||||
thrown = false;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
#endif
|
||||
{
|
||||
A a;
|
||||
reg_expression<C, T, A> e(expression.c_str(), flags[2] | regbase::use_except, a);
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
catch(const boost::bad_expression&)
|
||||
{
|
||||
thrown = true;
|
||||
@ -93,6 +100,7 @@ void cpp_eh_tests(const reg_expression<C, T, A>& )
|
||||
cout << "Error: expected exception not thrown" << endl;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class iterator>
|
||||
@ -515,6 +523,16 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
|
||||
if(flags[4] & REG_MERGE)
|
||||
return;
|
||||
|
||||
if(e.error_code())
|
||||
{
|
||||
if(search_text != BOOST_RE_STR("!"))
|
||||
{
|
||||
begin_error();
|
||||
cout << "Expression did not compile with class RegEx" << endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(recurse)
|
||||
{
|
||||
// copy and assign test:
|
||||
@ -611,13 +629,16 @@ void run_tests()
|
||||
return;
|
||||
#endif
|
||||
#ifndef NO_CPP_TEST
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
unsigned int f = flags[2] & ~regbase::use_except;
|
||||
if(flags[0] & REG_ICASE)
|
||||
f |= regbase::icase;
|
||||
re_type e(expression.c_str(), f);
|
||||
cpp_tests(e, true);
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
@ -634,17 +655,21 @@ void run_tests()
|
||||
begin_error();
|
||||
cout << "Unexpected exception thrown from C++ library" << endl;
|
||||
}
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#if !defined(TEST_UNICODE)
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
if(((flags[3] & match_partial) == 0) && (flags[2] == regbase::normal) && (has_nulls(search_text.begin(), search_text.end()) == false))
|
||||
{
|
||||
RegEx e;
|
||||
e.SetExpression(expression.c_str(), flags[0] & REG_ICASE);
|
||||
cpp_hl_tests(e, true);
|
||||
}
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(const std::exception& )
|
||||
{
|
||||
@ -659,6 +684,7 @@ void run_tests()
|
||||
begin_error();
|
||||
cout << "Unexpected exception thrown from RegEx::SetExpression" << endl;
|
||||
}
|
||||
#endif // BOOST_NO_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
if(flags[4] & (REG_NO_POSIX_TEST | REG_GREP | REG_MERGE | REG_MERGE_COPY))
|
||||
|
Reference in New Issue
Block a user