Added support for compilers with no exception handling support.

[SVN r12758]
This commit is contained in:
John Maddock
2002-02-08 12:44:43 +00:00
parent a5d1526fbb
commit c8e9df8fa2
12 changed files with 267 additions and 12 deletions

View File

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

View File

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