merged changes in regex5 branch

[SVN r26692]
This commit is contained in:
John Maddock
2005-01-13 17:06:21 +00:00
parent de0ab9092a
commit 71a0e020e2
275 changed files with 37305 additions and 27154 deletions

View File

@ -18,10 +18,10 @@
#ifndef BOOST_REGEX_CONFIG_HPP
#define BOOST_REGEX_CONFIG_HPP
/*
Borland C++ Fix/error check
this has to go *before* we include any std lib headers:
*/
//
// Borland C++ Fix/error check
// this has to go *before* we include any std lib headers:
//
#if defined(__BORLANDC__)
# include <boost/regex/config/borland.hpp>
#endif
@ -40,31 +40,14 @@
# include BOOST_REGEX_USER_CONFIG
# include <cstdlib>
# include <cstddef>
# include <cstdio>
# include <clocale>
# include <cassert>
# include <string>
# include <stdexcept>
# include <iterator>
# include <iosfwd>
# include <vector>
# include <boost/config.hpp>
# include <boost/cstdint.hpp>
# include <boost/regex/config/allocator.hpp>
# include <boost/regex/config/cstring.hpp>
# include <boost/throw_exception.hpp>
# include <boost/scoped_ptr.hpp>
# ifndef BOOST_NO_STD_LOCALE
# include <locale>
# endif
#else
/*
* C build,
* don't include <boost/config.hpp> because that may
* do C++ specific things in future...
*/
//
// C build,
// don't include <boost/config.hpp> because that may
// do C++ specific things in future...
//
# include <stdlib.h>
# include <stddef.h>
# ifdef _MSC_VER
@ -81,24 +64,34 @@
/* Obsolete macro, use BOOST_VERSION instead: */
#define BOOST_RE_VERSION 320
/* fix: */
// fix:
#if defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
/*
* If there isn't good enough wide character support then there will
* be no wide character regular expressions:
*/
//
// Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
// masks to be combined, for example:
// std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
// returns *false*.
//
#ifdef __GLIBCPP__
# define BOOST_REGEX_BUGGY_CTYPE_FACET
#endif
//
// If there isn't good enough wide character support then there will
// be no wide character regular expressions:
//
#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
# if !defined(BOOST_NO_WREGEX)
# define BOOST_NO_WREGEX
# endif
#else
# if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
/* STLPort on IRIX is misconfigured: <cwctype> does not compile
* as a temporary fix include <wctype.h> instead and prevent inclusion
* of STLPort version of <cwctype> */
// STLPort on IRIX is misconfigured: <cwctype> does not compile
// as a temporary fix include <wctype.h> instead and prevent inclusion
// of STLPort version of <cwctype>
# include <wctype.h>
# define __STLPORT_CWCTYPE
# define _STLP_CWCTYPE
@ -110,78 +103,28 @@
#endif
/*
* If Win32 support has been disabled for boost in general, then
* it is for regex in particular:
*/
//
// If Win32 support has been disabled for boost in general, then
// it is for regex in particular:
//
#if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
# define BOOST_REGEX_NO_W32
#endif
/* some versions of gcc can't merge template instances: */
#if defined(__CYGWIN__)
# define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
#endif
/* fix problems with bool as a macro,
* this probably doesn't affect any current compilers: */
#if defined(bool) || defined(true) || defined(false)
# define BOOST_REGEX_NO_BOOL
#endif
/* We don't make our templates external if the compiler
can't handle it: */
#if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__HP_aCC) || defined(__MWERKS__) || defined(__COMO__) || defined(BOOST_INTEL))\
&& !defined(BOOST_MSVC) && !defined(__BORLANDC__)
# define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
#endif
/* disable our own file-iterators and mapfiles if we can't
support them: */
// disable our own file-iterators and mapfiles if we can't
// support them:
#if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
# define BOOST_REGEX_NO_FILEITER
#endif
#ifdef __cplusplus
#ifndef MB_CUR_MAX
// yuk!
// better make a conservative guess!
#define MB_CUR_MAX 10
#endif
namespace boost{ namespace re_detail{
#ifdef BOOST_NO_STD_DISTANCE
template <class T>
std::ptrdiff_t distance(const T& x, const T& y)
{ return y - x; }
#else
using std::distance;
#endif
}}
#ifdef BOOST_REGEX_NO_BOOL
# define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
#else
# ifdef BOOST_MSVC
// warning suppression with VC6:
# pragma warning(disable: 4800)
# endif
# define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
#endif
#endif /* __cplusplus */
/* backwards compatibitity: */
// backwards compatibitity:
#if defined(BOOST_RE_NO_LIB)
# define BOOST_REGEX_NO_LIB
#endif
#if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
// gcc on win32 has problems merging switch statements in templates:
# define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
// gcc on win32 has problems if you include <windows.h>
// (sporadically generates bad code).
# define BOOST_REGEX_USE_C_LOCALE
# define BOOST_REGEX_NO_W32
#endif
#if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
@ -194,13 +137,26 @@ using std::distance;
*
****************************************************************************/
#ifdef __cplusplus
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) && !defined(BOOST_REGEX_V3) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
# define BOOST_REGEX_HAS_SHORT_WCHAR_T
namespace boost{ typedef __wchar_t regex_wchar_type; }
#else
namespace boost{ typedef wchar_t regex_wchar_type; }
#endif
//
// define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
// code may be built with wchar_t as unsigned short: basically when we're building
// with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
// of the non-inline functions in the library, so that users can still link to the lib,
// irrespective of whether their own code is built with /Zc:wchar_t.
//
#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS)
# define BOOST_REGEX_HAS_OTHER_WCHAR_T
# ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4251 4231 4660)
# endif
# ifdef _DLL
# include <string>
extern template class __declspec(dllimport) std::basic_string<unsigned short>;
# endif
# ifdef BOOST_MSVC
# pragma warning(pop)
# endif
#endif
@ -228,9 +184,9 @@ namespace boost{ typedef wchar_t regex_wchar_type; }
# if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
# define BOOST_DYN_LINK
# endif
#ifdef BOOST_REGEX_DIAG
# define BOOST_LIB_DIAGNOSTIC
#endif
# ifdef BOOST_REGEX_DIAG
# define BOOST_LIB_DIAGNOSTIC
# endif
# include <boost/config/auto_link.hpp>
#endif
@ -267,7 +223,7 @@ namespace boost{ typedef wchar_t regex_wchar_type; }
*
****************************************************************************/
/* backwards compatibility: */
// backwards compatibility:
#ifdef BOOST_RE_LOCALE_C
# define BOOST_REGEX_USE_C_LOCALE
#endif
@ -276,29 +232,19 @@ namespace boost{ typedef wchar_t regex_wchar_type; }
# define BOOST_REGEX_USE_CPP_LOCALE
#endif
/* Win32 defaults to native Win32 locale: */
// Win32 defaults to native Win32 locale:
#if defined(_WIN32) && !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_REGEX_NO_W32)
# define BOOST_REGEX_USE_WIN32_LOCALE
#endif
/* otherwise use C locale: */
// otherwise use C++ locale if supported:
#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
# define BOOST_REGEX_USE_CPP_LOCALE
#endif
// otherwise use C+ locale:
#if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
# define BOOST_REGEX_USE_C_LOCALE
#endif
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
# include <windows.h>
#endif
#ifdef MAXPATH
# define BOOST_REGEX_MAX_PATH MAXPATH
#elif defined(MAX_PATH)
# define BOOST_REGEX_MAX_PATH MAX_PATH
#elif defined(FILENAME_MAX)
# define BOOST_REGEX_MAX_PATH FILENAME_MAX
#else
# define BOOST_REGEX_MAX_PATH 200
#endif
#ifndef BOOST_REGEX_MAX_STATE_COUNT
# define BOOST_REGEX_MAX_STATE_COUNT 100000000
#endif
@ -311,10 +257,14 @@ namespace boost{ typedef wchar_t regex_wchar_type; }
****************************************************************************/
#ifdef BOOST_NO_EXCEPTIONS
/*
* If there are no exceptions then we must report critical-errors
* the only way we know how; by terminating.
*/
//
// If there are no exceptions then we must report critical-errors
// the only way we know how; by terminating.
//
#include <stdexcept>
#include <string>
#include <boost/throw_exception.hpp>
# define BOOST_REGEX_NOEH_ASSERT(x)\
if(0 == (x))\
{\
@ -324,70 +274,13 @@ if(0 == (x))\
boost::throw_exception(e);\
}
#else
/*
* With exceptions then error handling is taken care of and
* there is no need for these checks:
*/
//
// 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:
*
****************************************************************************/
#if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
# include <iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::endl;
using std::hex;
using std::dec;
# ifndef jm_assert
# define jm_assert(x) assert(x)
# endif
# ifndef jm_trace
# define jm_trace(x) cerr << x << endl;
# endif
# ifndef jm_instrument
# define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
# endif
namespace boost{
namespace re_detail{
class debug_guard
{
public:
char g1[32];
const char* pc;
char* pnc;
const char* file;
int line;
char g2[32];
debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
~debug_guard();
};
# define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
# define BOOST_RE_GUARD_GLOBAL(x) const char g1##x[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; char g2##x[32]; boost::debug_guard g3##x(__FILE__, __LINE__, g1##x, g2##x);
} // namespace re_detail
} // namespace boost
#else
# define jm_assert(x)
# define jm_trace(x)
# define BOOST_RE_GUARD_STACK
# define BOOST_RE_GUARD_GLOBAL(x)
# ifndef jm_instrument
# define jm_instrument
# endif
#endif
/*****************************************************************************
*
@ -419,31 +312,6 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
#endif
/*****************************************************************************
*
* Error handling:
*
****************************************************************************/
#if defined(__cplusplus)
namespace boost{
namespace re_detail{
BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& s);
template <class traits>
void raise_error(const traits& t, unsigned code)
{
(void)t; // warning suppression
raise_regex_exception(t.error_string(code));
}
}
}
#endif
/*****************************************************************************
*
* Algorithm selection and configuration:
@ -480,93 +348,6 @@ void raise_error(const traits& t, unsigned code)
#endif
/*****************************************************************************
*
* Fix broken compilers that wrongly #define some symbols:
*
****************************************************************************/
#ifdef __cplusplus
// the following may be defined as macros; this is
// incompatable with std::something syntax, we have
// no choice but to undef them?
#ifdef sprintf
#undef sprintf
#endif
#ifdef swprintf
#undef swprintf
#endif
#endif
/*****************************************************************************
*
* Fix broken broken namespace support:
*
****************************************************************************/
#if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
namespace std{
using ::ptrdiff_t;
using ::size_t;
using ::sprintf;
using ::abs;
using ::setlocale;
# ifndef BOOST_NO_WREGEX
# ifndef BOOST_NO_SWPRINTF
using ::swprintf;
# endif
using ::wcstombs;
using ::mbstowcs;
# if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
using ::mbstate_t;
# endif
# endif /* BOOST_NO_WREGEX */
using ::fseek;
using ::fread;
using ::ftell;
using ::fopen;
using ::fclose;
using ::FILE;
#ifdef BOOST_NO_EXCEPTIONS
using ::fprintf;
using ::abort;
#endif
}
#endif
/*****************************************************************************
*
* helper functions pointer_construct/pointer_destroy:
*
****************************************************************************/
#ifdef __cplusplus
namespace boost{ namespace re_detail{
#ifdef BOOST_MSVC
#pragma warning (push)
#pragma warning (disable : 4100)
#endif
template <class T>
inline void pointer_destroy(T* p)
{ p->~T(); (void)p; }
#ifdef BOOST_MSVC
#pragma warning (pop)
#endif
template <class T>
inline void pointer_construct(T* p, const T& t)
{ new (p) T(t); }
}} // namespaces
#endif
/*****************************************************************************
*
* helper memory allocation functions:
@ -593,9 +374,9 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
#endif
#if defined(BOOST_REGEX_DIAG)
# pragma message ("BOOST_REGEX_DECL set as: " BOOST_STRINGIZE(BOOST_REGEX_DECL))
# pragma message ("BOOST_REGEX_CALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CALL))
# pragma message ("BOOST_REGEX_CCALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CCALL))
# pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
# pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
# pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
#ifdef BOOST_REGEX_USE_C_LOCALE
# pragma message ("Using C locale in regex traits class")
#elif BOOST_REGEX_USE_CPP_LOCALE
@ -603,20 +384,15 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
#else
# pragma message ("Using Win32 locale in regex traits class")
#endif
#ifdef BOOST_REGEX_DYN_LINK
#if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
# pragma message ("Dynamic linking enabled")
#endif
#ifdef BOOST_REGEX_NO_LIB
#if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
# pragma message ("Auto-linking disabled")
#endif
#ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
# pragma message ("Extern templates disabled")
#endif
#ifdef BOOST_REGEX_V3
# pragma message ("Using Version 3 regex code")
#else
# pragma message ("Using Version 4 regex code")
#endif
#endif