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