mirror of
https://github.com/boostorg/regex.git
synced 2025-07-23 00:57:19 +02:00
Added support for compilers with no exception handling support.
[SVN r12758]
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user