]> git.lyx.org Git - lyx.git/blob - boost/boost/regex/config.hpp
update to boost 1.32.0
[lyx.git] / boost / boost / regex / config.hpp
1 /*
2  *
3  * Copyright (c) 1998-2002
4  * Dr John Maddock
5  *
6  * Use, modification and distribution are subject to the
7  * Boost Software License, Version 1.0. (See accompanying file
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9  *
10  */
11
12  /*
13   *   LOCATION:    see http://www.boost.org for most recent version.
14   *   FILE         config.hpp
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: regex extended config setup.
17   */
18
19 #ifndef BOOST_REGEX_CONFIG_HPP
20 #define BOOST_REGEX_CONFIG_HPP
21 /*
22  Borland C++ Fix/error check
23  this has to go *before* we include any std lib headers:
24 */
25 #if defined(__BORLANDC__)
26 #  include <boost/regex/config/borland.hpp>
27 #endif
28
29 /*****************************************************************************
30  *
31  *  Include all the headers we need here:
32  *
33  ****************************************************************************/
34
35 #ifdef __cplusplus
36
37 #  ifndef BOOST_REGEX_USER_CONFIG
38 #     define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
39 #  endif
40
41 #  include BOOST_REGEX_USER_CONFIG
42
43 #  include <cstdlib>
44 #  include <cstddef>
45 #  include <cstdio>
46 #  include <clocale>
47 #  include <cassert>
48 #  include <string>
49 #  include <stdexcept>
50 #  include <iterator>
51 #  include <iosfwd>
52 #  include <vector>
53 #  include <boost/config.hpp>
54 #  include <boost/cstdint.hpp>
55 #  include <boost/regex/config/allocator.hpp>
56 #  include <boost/regex/config/cstring.hpp>
57 #  include <boost/throw_exception.hpp>
58 #  include <boost/scoped_ptr.hpp>
59 #  ifndef BOOST_NO_STD_LOCALE
60 #     include <locale>
61 #  endif
62 #else
63    /*
64    * C build,
65    * don't include <boost/config.hpp> because that may
66    * do C++ specific things in future...
67    */
68 #  include <stdlib.h>
69 #  include <stddef.h>
70 #  ifdef _MSC_VER
71 #     define BOOST_MSVC _MSC_VER
72 #  endif
73 #endif
74
75 /*****************************************************************************
76  *
77  *  Boilerplate regex config options:
78  *
79  ****************************************************************************/
80
81 /* Obsolete macro, use BOOST_VERSION instead: */
82 #define BOOST_RE_VERSION 320
83
84 /* fix: */
85 #if defined(_UNICODE) && !defined(UNICODE)
86 #define UNICODE
87 #endif
88
89 /*
90 * If there isn't good enough wide character support then there will
91 * be no wide character regular expressions:
92 */
93 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
94 #  if !defined(BOOST_NO_WREGEX)
95 #     define BOOST_NO_WREGEX
96 #  endif
97 #else
98 #  if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
99       /* STLPort on IRIX is misconfigured: <cwctype> does not compile
100       * as a temporary fix include <wctype.h> instead and prevent inclusion
101       * of STLPort version of <cwctype> */
102 #     include <wctype.h>
103 #     define __STLPORT_CWCTYPE
104 #     define _STLP_CWCTYPE
105 #  endif
106
107 #ifdef __cplusplus
108 #  include <boost/regex/config/cwchar.hpp>
109 #endif
110
111 #endif
112
113 /*
114 * If Win32 support has been disabled for boost in general, then
115 * it is for regex in particular:
116 */
117 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
118 #  define BOOST_REGEX_NO_W32
119 #endif
120
121 /* some versions of gcc can't merge template instances: */
122 #if defined(__CYGWIN__)
123 #  define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
124 #endif
125
126 /* fix problems with bool as a macro,
127 * this probably doesn't affect any current compilers: */
128 #if defined(bool) || defined(true) || defined(false)
129 #  define BOOST_REGEX_NO_BOOL
130 #endif
131
132 /* We don't make our templates external if the compiler
133  can't handle it: */
134 #if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__HP_aCC) || defined(__MWERKS__) || defined(__COMO__) || defined(BOOST_INTEL))\
135    && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
136 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
137 #endif
138
139 /* disable our own file-iterators and mapfiles if we can't
140  support them: */
141 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
142 #  define BOOST_REGEX_NO_FILEITER
143 #endif
144
145 #ifdef __cplusplus
146 #ifndef MB_CUR_MAX
147 // yuk!
148 // better make a conservative guess!
149 #define MB_CUR_MAX 10
150 #endif
151
152 namespace boost{ namespace re_detail{
153 #ifdef BOOST_NO_STD_DISTANCE
154 template <class T>
155 std::ptrdiff_t distance(const T& x, const T& y)
156 { return y - x; }
157 #else
158 using std::distance;
159 #endif
160 }}
161
162
163 #ifdef BOOST_REGEX_NO_BOOL
164 #  define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
165 #else
166 #  ifdef BOOST_MSVC
167       // warning suppression with VC6:
168 #     pragma warning(disable: 4800)
169 #  endif
170 #  define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
171 #endif
172 #endif /* __cplusplus */
173
174 /* backwards compatibitity: */
175 #if defined(BOOST_RE_NO_LIB)
176 #  define BOOST_REGEX_NO_LIB
177 #endif
178
179 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
180 // gcc on win32 has problems merging switch statements in templates:
181 #  define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
182 // gcc on win32 has problems if you include <windows.h>
183 // (sporadically generates bad code).
184 #  define BOOST_REGEX_USE_C_LOCALE
185 #  define BOOST_REGEX_NO_W32
186 #endif
187 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
188 #  define BOOST_REGEX_NO_W32
189 #endif
190
191 /*****************************************************************************
192  *
193  *  Wide character workarounds:
194  *
195  ****************************************************************************/
196
197 #ifdef __cplusplus
198 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) && !defined(BOOST_REGEX_V3) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
199 #  define BOOST_REGEX_HAS_SHORT_WCHAR_T
200 namespace boost{ typedef __wchar_t regex_wchar_type; }
201 #else
202 namespace boost{ typedef wchar_t regex_wchar_type; }
203 #endif
204 #endif
205
206
207 /*****************************************************************************
208  *
209  *  Set up dll import/export options:
210  *
211  ****************************************************************************/
212
213 #if defined(BOOST_HAS_DECLSPEC) && (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
214 #  if defined(BOOST_REGEX_SOURCE)
215 #     define BOOST_REGEX_DECL __declspec(dllexport)
216 #     define BOOST_REGEX_BUILD_DLL
217 #  else
218 #     define BOOST_REGEX_DECL __declspec(dllimport)
219 #  endif
220 #endif
221
222 #ifndef BOOST_REGEX_DECL
223 #  define BOOST_REGEX_DECL
224 #endif
225
226 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
227 #  define BOOST_LIB_NAME boost_regex
228 #  if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
229 #     define BOOST_DYN_LINK
230 #  endif
231 #ifdef BOOST_REGEX_DIAG
232 #  define BOOST_LIB_DIAGNOSTIC
233 #endif
234 #  include <boost/config/auto_link.hpp>
235 #endif
236
237 /*****************************************************************************
238  *
239  *  Set up function call type:
240  *
241  ****************************************************************************/
242
243 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS)
244 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS)
245 #  define BOOST_REGEX_CALL __cdecl
246 #else
247 #  define BOOST_REGEX_CALL __fastcall
248 #endif
249 #  define BOOST_REGEX_CCALL __cdecl
250 #endif
251
252 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
253 #  define BOOST_REGEX_CALL __fastcall
254 #  define BOOST_REGEX_CCALL __stdcall
255 #endif
256
257 #ifndef BOOST_REGEX_CALL
258 #  define BOOST_REGEX_CALL
259 #endif
260 #ifndef BOOST_REGEX_CCALL
261 #define BOOST_REGEX_CCALL
262 #endif
263
264 /*****************************************************************************
265  *
266  *  Set up localisation model:
267  *
268  ****************************************************************************/
269
270 /* backwards compatibility: */
271 #ifdef BOOST_RE_LOCALE_C
272 #  define BOOST_REGEX_USE_C_LOCALE
273 #endif
274
275 #ifdef BOOST_RE_LOCALE_CPP
276 #  define BOOST_REGEX_USE_CPP_LOCALE
277 #endif
278
279 /* Win32 defaults to native Win32 locale: */
280 #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)
281 #  define BOOST_REGEX_USE_WIN32_LOCALE
282 #endif
283 /* otherwise use C locale: */
284 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
285 #  define BOOST_REGEX_USE_C_LOCALE
286 #endif
287
288 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
289 #  include <windows.h>
290 #endif
291
292 #ifdef MAXPATH
293 #  define BOOST_REGEX_MAX_PATH MAXPATH
294 #elif defined(MAX_PATH)
295 #  define BOOST_REGEX_MAX_PATH MAX_PATH
296 #elif defined(FILENAME_MAX)
297 #  define BOOST_REGEX_MAX_PATH FILENAME_MAX
298 #else
299 #  define BOOST_REGEX_MAX_PATH 200
300 #endif
301
302 #ifndef BOOST_REGEX_MAX_STATE_COUNT
303 #  define BOOST_REGEX_MAX_STATE_COUNT 100000000
304 #endif
305
306
307 /*****************************************************************************
308  *
309  *  Error Handling for exception free compilers:
310  *
311  ****************************************************************************/
312
313 #ifdef BOOST_NO_EXCEPTIONS
314 /*
315 *  If there are no exceptions then we must report critical-errors
316 *  the only way we know how; by terminating.
317 */
318 #  define BOOST_REGEX_NOEH_ASSERT(x)\
319 if(0 == (x))\
320 {\
321    std::string s("Error: critical regex++ failure in: ");\
322    s.append(#x);\
323    std::runtime_error e(s);\
324    boost::throw_exception(e);\
325 }
326 #else
327 /*
328 *  With exceptions then error handling is taken care of and
329 *  there is no need for these checks:
330 */
331 #  define BOOST_REGEX_NOEH_ASSERT(x)
332 #endif
333
334 /*****************************************************************************
335  *
336  *  Debugging / tracing support:
337  *
338  ****************************************************************************/
339
340 #if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
341
342 #  include <iostream>
343 using std::cout;
344 using std::cin;
345 using std::cerr;
346 using std::endl;
347 using std::hex;
348 using std::dec;
349
350 #  ifndef jm_assert
351 #     define jm_assert(x) assert(x)
352 #  endif
353 #  ifndef jm_trace
354 #     define jm_trace(x) cerr << x << endl;
355 #  endif
356 #  ifndef jm_instrument
357 #     define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
358 #  endif
359
360 namespace boost{
361    namespace re_detail{
362 class debug_guard
363 {
364 public:
365    char g1[32];
366    const char* pc;
367    char* pnc;
368    const char* file;
369    int line;
370    char g2[32];
371    debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
372    ~debug_guard();
373 };
374
375 #  define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
376 #  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);
377
378    } // namespace re_detail
379 } // namespace boost
380
381 #else
382
383 #  define jm_assert(x)
384 #  define jm_trace(x)
385 #  define BOOST_RE_GUARD_STACK
386 #  define BOOST_RE_GUARD_GLOBAL(x)
387 #  ifndef jm_instrument
388 #     define jm_instrument
389 #  endif
390 #endif
391
392 /*****************************************************************************
393  *
394  *  Stack protection under MS Windows:
395  *
396  ****************************************************************************/
397
398 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
399 #  if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
400         && !defined(__GNUC__) \
401         && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
402         && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
403 #     define BOOST_REGEX_HAS_MS_STACK_GUARD
404 #  endif
405 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
406 #  undef BOOST_REGEX_HAS_MS_STACK_GUARD
407 #endif
408
409 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
410
411 namespace boost{
412 namespace re_detail{
413
414 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
415
416 }
417 }
418
419 #endif
420
421
422 /*****************************************************************************
423  *
424  *  Error handling:
425  *
426  ****************************************************************************/
427
428 #if defined(__cplusplus)
429
430 namespace boost{
431 namespace re_detail{
432
433 BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& s);
434
435 template <class traits>
436 void raise_error(const traits& t, unsigned code)
437 {
438    (void)t;  // warning suppression
439    raise_regex_exception(t.error_string(code));
440 }
441
442 }
443 }
444
445 #endif
446
447 /*****************************************************************************
448  *
449  *  Algorithm selection and configuration:
450  *
451  ****************************************************************************/
452
453 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
454 #  if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG)
455 #     define BOOST_REGEX_RECURSIVE
456 #  else
457 #     define BOOST_REGEX_NON_RECURSIVE
458 #  endif
459 #endif
460
461 #ifdef BOOST_REGEX_NON_RECURSIVE
462 #  ifdef BOOST_REGEX_RECURSIVE
463 #     error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
464 #  endif
465 #  ifndef BOOST_REGEX_BLOCKSIZE
466 #     define BOOST_REGEX_BLOCKSIZE 4096
467 #  endif
468 #  if BOOST_REGEX_BLOCKSIZE < 512
469 #     error "BOOST_REGEX_BLOCKSIZE must be at least 512"
470 #  endif
471 #  ifndef BOOST_REGEX_MAX_BLOCKS
472 #     define BOOST_REGEX_MAX_BLOCKS 1024
473 #  endif
474 #  ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
475 #     undef BOOST_REGEX_HAS_MS_STACK_GUARD
476 #  endif
477 #  ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
478 #     define BOOST_REGEX_MAX_CACHE_BLOCKS 16
479 #  endif
480 #endif
481
482
483 /*****************************************************************************
484  *
485  *  Fix broken compilers that wrongly #define some symbols:
486  *
487  ****************************************************************************/
488
489 #ifdef __cplusplus
490
491 // the following may be defined as macros; this is
492 // incompatable with std::something syntax, we have
493 // no choice but to undef them?
494
495 #ifdef sprintf
496 #undef sprintf
497 #endif
498 #ifdef swprintf
499 #undef swprintf
500 #endif
501 #endif
502
503 /*****************************************************************************
504  *
505  *  Fix broken broken namespace support:
506  *
507  ****************************************************************************/
508
509 #if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
510
511 namespace std{
512    using ::ptrdiff_t;
513    using ::size_t;
514    using ::sprintf;
515    using ::abs;
516    using ::setlocale;
517 #  ifndef BOOST_NO_WREGEX
518 #     ifndef BOOST_NO_SWPRINTF
519    using ::swprintf;
520 #     endif
521    using ::wcstombs;
522    using ::mbstowcs;
523 #     if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
524    using ::mbstate_t;
525 #     endif
526 #  endif /* BOOST_NO_WREGEX */
527    using ::fseek;
528    using ::fread;
529    using ::ftell;
530    using ::fopen;
531    using ::fclose;
532    using ::FILE;
533 #ifdef BOOST_NO_EXCEPTIONS
534    using ::fprintf;
535    using ::abort;
536 #endif
537 }
538
539 #endif
540
541 /*****************************************************************************
542  *
543  *  helper functions pointer_construct/pointer_destroy:
544  *
545  ****************************************************************************/
546
547 #ifdef __cplusplus
548 namespace boost{ namespace re_detail{
549
550 #ifdef BOOST_MSVC
551 #pragma warning (push)
552 #pragma warning (disable : 4100)
553 #endif
554
555 template <class T>
556 inline void pointer_destroy(T* p)
557 { p->~T(); (void)p; }
558
559 #ifdef BOOST_MSVC
560 #pragma warning (pop)
561 #endif
562
563 template <class T>
564 inline void pointer_construct(T* p, const T& t)
565 { new (p) T(t); }
566
567 }} // namespaces
568 #endif
569
570 /*****************************************************************************
571  *
572  *  helper memory allocation functions:
573  *
574  ****************************************************************************/
575
576 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
577 namespace boost{ namespace re_detail{
578
579 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
580 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
581
582 }} // namespaces
583 #endif
584
585 /*****************************************************************************
586  *
587  *  Diagnostics:
588  *
589  ****************************************************************************/
590
591 #ifdef BOOST_REGEX_CONFIG_INFO
592 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
593 #endif
594
595 #if defined(BOOST_REGEX_DIAG)
596 #  pragma message ("BOOST_REGEX_DECL set as: " BOOST_STRINGIZE(BOOST_REGEX_DECL))
597 #  pragma message ("BOOST_REGEX_CALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CALL))
598 #  pragma message ("BOOST_REGEX_CCALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CCALL))
599 #ifdef BOOST_REGEX_USE_C_LOCALE
600 #  pragma message ("Using C locale in regex traits class")
601 #elif BOOST_REGEX_USE_CPP_LOCALE
602 #  pragma message ("Using C++ locale in regex traits class")
603 #else
604 #  pragma message ("Using Win32 locale in regex traits class")
605 #endif
606 #ifdef BOOST_REGEX_DYN_LINK
607 #  pragma message ("Dynamic linking enabled")
608 #endif
609 #ifdef BOOST_REGEX_NO_LIB
610 #  pragma message ("Auto-linking disabled")
611 #endif
612 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
613 #  pragma message ("Extern templates disabled")
614 #endif
615 #ifdef BOOST_REGEX_V3
616 #  pragma message ("Using Version 3 regex code")
617 #else
618 #  pragma message ("Using Version 4 regex code")
619 #endif
620
621 #endif
622
623 #endif
624
625
626
627