]> git.lyx.org Git - lyx.git/blob - boost/boost/regex/config.hpp
update boost to pre-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)) && !defined(BOOST_NO_WREGEX)
129 #  define BOOST_NO_WREGEX
130 #else
131 #  if defined(__sgi) && defined(__SGI_STL_PORT)
132       // STLPort on IRIX is misconfigured: <cwctype> does not compile
133       // as a temporary fix include <wctype.h> instead and prevent inclusion
134       // of STLPort version of <cwctype>
135 #     include <wctype.h>
136 #     define __STLPORT_CWCTYPE
137 #     define _STLP_CWCTYPE
138 #  endif
139
140 #ifdef __cplusplus
141 #  include <cwchar>
142 #  include <cwctype>
143 #endif
144
145 #endif
146
147 //
148 // If Win32 support has been disabled for boost in general, then
149 // it is for regex in particular:
150 //
151 #ifdef BOOST_DISABLE_WIN32
152 #  define BOOST_REGEX_NO_W32
153 #endif
154
155 // some versions of gcc can't merge template instances:
156 #if defined(__CYGWIN__)
157 #  define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
158 #endif
159
160 // fix problems with bool as a macro,
161 // this probably doesn't affect any current compilers:
162 #if defined(bool) || defined(true) || defined(false)
163 #  define BOOST_REGEX_NO_BOOL
164 #endif
165
166 // We don't make our templates external if the compiler
167 // can't handle it:
168 #if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__HP_aCC) || defined(__MWERKS__) || defined(__COMO__) || defined(__ICL) || defined(__ICC))\
169    && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
170 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
171 #endif
172
173 // disable our own file-iterators and mapfiles if we can't
174 // support them:
175 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
176 #  define BOOST_REGEX_NO_FILEITER
177 #endif
178
179 #ifdef __cplusplus
180 #ifndef MB_CUR_MAX
181 // yuk!
182 // better make a conservative guess!
183 #define MB_CUR_MAX 10
184 #endif
185
186 namespace boost{ namespace re_detail{
187 #ifdef BOOST_NO_STD_DISTANCE
188 template <class T>
189 std::ptrdiff_t distance(const T& x, const T& y)
190 { return y - x; }
191 #else
192 using std::distance;
193 #endif
194 }}
195
196
197 #ifdef BOOST_REGEX_NO_BOOL
198 #  define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
199 #else
200 #  ifdef BOOST_MSVC
201       // warning suppression with VC6:
202 #     pragma warning(disable: 4800)
203 #  endif
204 #  define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
205 #endif
206 #endif // __cplusplus
207
208 // backwards compatibitity:
209 #if defined(BOOST_RE_NO_LIB)
210 #  define BOOST_REGEX_NO_LIB
211 #endif
212
213 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
214 // gcc on win32 has problems merging switch statements in templates:
215 #  define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
216 // gcc on win32 has problems if you include <windows.h>
217 // (sporadically generates bad code).
218 #  define BOOST_REGEX_USE_C_LOCALE
219 #  define BOOST_REGEX_NO_W32
220 #endif
221
222
223 /*****************************************************************************
224  *
225  *  Set up dll import/export options:
226  *
227  ****************************************************************************/
228
229 // backwards compatibility:
230 #ifdef BOOST_RE_STATIC_LIB
231 #  define BOOST_REGEX_STATIC_LINK
232 #endif
233
234 #if defined(BOOST_MSVC) && defined(_DLL)
235 #  define BOOST_REGEX_HAS_DLL_RUNTIME
236 #endif
237
238 #if defined(__BORLANDC__) && defined(_RTLDLL)
239 #  define BOOST_REGEX_HAS_DLL_RUNTIME
240 #endif
241
242 #if defined(__ICL) && defined(_DLL)
243 #  define BOOST_REGEX_HAS_DLL_RUNTIME
244 #endif
245
246 #if defined(BOOST_REGEX_HAS_DLL_RUNTIME) && !defined(BOOST_REGEX_STATIC_LINK)
247 #  if defined(BOOST_REGEX_SOURCE)
248 #     define BOOST_REGEX_DECL __declspec(dllexport)
249 #     define BOOST_REGEX_BUILD_DLL
250 #  else
251 #     define BOOST_REGEX_DECL __declspec(dllimport)
252 #  endif
253 #endif
254
255 #ifndef BOOST_REGEX_DECL
256 #  define BOOST_REGEX_DECL
257 #endif
258  
259 #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE)
260 #  include <boost/regex/v3/regex_library_include.hpp>
261 #endif
262
263 /*****************************************************************************
264  *
265  *  Set up function call type:
266  *
267  ****************************************************************************/
268
269 #if defined(BOOST_MSVC) || defined(__ICL)
270 #  if defined(_DEBUG)
271 #     define BOOST_REGEX_CALL __cdecl
272 #  else
273 #     define BOOST_REGEX_CALL __fastcall
274 #  endif
275 #  define BOOST_REGEX_CCALL __stdcall
276 #endif
277
278 #if defined(__BORLANDC__)
279 #  define BOOST_REGEX_CALL __fastcall
280 #  define BOOST_REGEX_CCALL __stdcall
281 #endif
282
283 #ifndef BOOST_REGEX_CALL
284 #  define BOOST_REGEX_CALL
285 #endif
286 #ifndef BOOST_REGEX_CCALL
287 #define BOOST_REGEX_CCALL
288 #endif
289
290 /*****************************************************************************
291  *
292  *  Set up localisation model:
293  *
294  ****************************************************************************/
295
296 // backwards compatibility:
297 #ifdef BOOST_RE_LOCALE_C
298 #  define BOOST_REGEX_USE_C_LOCALE
299 #endif
300
301 #ifdef BOOST_RE_LOCALE_CPP
302 #  define BOOST_REGEX_USE_CPP_LOCALE
303 #endif
304
305 // Win32 defaults to native Win32 locale:
306 #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)
307 #  define BOOST_REGEX_USE_WIN32_LOCALE
308 #endif
309 // otherwise use C locale:
310 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
311 #  define BOOST_REGEX_USE_C_LOCALE
312 #endif
313
314 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
315 #  include <windows.h>
316 #endif
317
318 #ifdef MAXPATH
319 #  define BOOST_REGEX_MAX_PATH MAXPATH
320 #elif defined(MAX_PATH)
321 #  define BOOST_REGEX_MAX_PATH MAX_PATH
322 #elif defined(FILENAME_MAX)
323 #  define BOOST_REGEX_MAX_PATH FILENAME_MAX
324 #else
325 #  define BOOST_REGEX_MAX_PATH 200
326 #endif
327
328
329
330 /*****************************************************************************
331  *
332  *  Error Handling for exception free compilers:
333  *
334  ****************************************************************************/
335
336 #ifdef BOOST_NO_EXCEPTIONS
337 //
338 // If there are no exceptions then we must report critical-errors
339 // the only way we know how; by terminating.
340 //
341 #ifdef __BORLANDC__
342 // <cstdio> seems not to make stderr usable with Borland:
343 #include <stdio.h>
344 #endif
345 #  define BOOST_REGEX_NOEH_ASSERT(x)\
346 if(0 == (x))\
347 {\
348    std::fprintf(stderr, "Error: critical regex++ failure in \"%s\"", #x);\
349    std::abort();\
350 }
351 #else
352 //
353 // With exceptions then error handling is taken care of and
354 // there is no need for these checks:
355 //
356 #  define BOOST_REGEX_NOEH_ASSERT(x)
357 #endif
358
359 /*****************************************************************************
360  *
361  *  Debugging / tracing support:
362  *
363  ****************************************************************************/
364
365 #if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
366
367 #  include <iostream>
368 using std::cout;
369 using std::cin;
370 using std::cerr;
371 using std::endl;
372 using std::hex;
373 using std::dec;
374
375 #  ifndef jm_assert
376 #     define jm_assert(x) assert(x)
377 #  endif
378 #  ifndef jm_trace
379 #     define jm_trace(x) cerr << x << endl;
380 #  endif
381 #  ifndef jm_instrument
382 #     define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
383 #  endif
384
385 namespace boost{
386    namespace re_detail{
387 class debug_guard
388 {
389 public:
390    char g1[32];
391    const char* pc;
392    char* pnc;
393    const char* file;
394    int line;
395    char g2[32];
396    debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
397    ~debug_guard();
398 };
399
400 #  define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
401 #  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);
402
403    } // namespace re_detail
404 } // namespace boost
405
406 #else
407
408 #  define jm_assert(x)
409 #  define jm_trace(x)
410 #  define BOOST_RE_GUARD_STACK
411 #  define BOOST_RE_GUARD_GLOBAL(x)
412 #  ifndef jm_instrument
413 #     define jm_instrument
414 #  endif
415 #endif
416
417 /*****************************************************************************
418  *
419  *  Fix broken compilers that wrongly #define some symbols:
420  *
421  ****************************************************************************/
422
423 #ifdef __cplusplus
424
425 #ifdef BOOST_NO_CTYPE_FUNCTIONS
426
427 // Make functions out of the macros.
428 // Use parentheses so the macros don't screw us up.
429 inline int (isalpha)(int c) { return isalpha(c); }
430 inline int (iscntrl)(int c) { return iscntrl(c); }
431 inline int (isdigit)(int c) { return isdigit(c); }
432 inline int (islower)(int c) { return islower(c); }
433 inline int (ispunct)(int c) { return ispunct(c); }
434 inline int (isspace)(int c) { return isspace(c); }
435 inline int (isupper)(int c) { return isupper(c); }
436 inline int (isxdigit)(int c) { return isxdigit(c); }
437
438 #endif
439
440 // the following may be defined as macros; this is
441 // incompatable with std::something syntax, we have
442 // no choice but to undef them?
443
444 #ifdef memcpy
445 #undef memcpy
446 #endif
447 #ifdef memmove
448 #undef memmove
449 #endif
450 #ifdef memset
451 #undef memset
452 #endif
453 #ifdef sprintf
454 #undef sprintf
455 #endif
456 #ifdef strcat
457 #undef strcat
458 #endif
459 #ifdef strcmp
460 #undef strcmp
461 #endif
462 #ifdef strcpy
463 #undef strcpy
464 #endif
465 #ifdef strlen
466 #undef strlen
467 #endif
468 #ifdef swprintf
469 #undef swprintf
470 #endif
471 #ifdef wcslen
472 #undef wcslen
473 #endif
474 #ifdef wcscpy
475 #undef wcscpy
476 #endif
477 #ifdef wcscmp
478 #undef wcscmp
479 #endif
480 #ifdef isalpha
481 #undef isalpha
482 #endif
483 #ifdef iscntrl
484 #undef iscntrl
485 #endif
486 #ifdef isdigit
487 #undef isdigit
488 #endif
489 #ifdef islower
490 #undef islower
491 #endif
492 #ifdef isupper
493 #undef isupper
494 #endif
495 #ifdef ispunct
496 #undef ispunct
497 #endif
498 #ifdef isspace
499 #undef isspace
500 #endif
501 #ifdef isxdigit
502 #undef isxdigit
503 #endif
504
505 #ifdef tolower
506 #undef tolower
507 #endif
508 #ifdef iswalpha
509 #undef iswalpha
510 #endif
511 #ifdef iswcntrl
512 #undef iswcntrl
513 #endif
514 #ifdef iswdigit
515 #undef iswdigit
516 #endif
517 #ifdef iswlower
518 #undef iswlower
519 #endif
520 #ifdef iswpunct
521 #undef iswpunct
522 #endif
523 #ifdef iswspace
524 #undef iswspace
525 #endif
526 #ifdef iswupper
527 #undef iswupper
528 #endif
529 #ifdef iswxdigit
530 #undef iswxdigit
531 #endif
532 #ifdef towlower
533 #undef towlower
534 #endif
535 #ifdef wcsxfrm
536 #undef wcsxfrm
537 #endif
538
539 #endif
540
541 /*****************************************************************************
542  *
543  *  Fix broken broken namespace support:
544  *
545  ****************************************************************************/
546
547 #if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
548
549 namespace std{
550    using ::ptrdiff_t;
551    using ::size_t;
552    using ::memcpy;
553    using ::memmove;
554    using ::memset;
555    using ::memcmp;
556    using ::sprintf;
557    using ::strcat;
558    using ::strcmp;
559    using ::strcpy;
560    using ::strlen;
561    using ::strxfrm;
562    using ::isalpha;
563    using ::iscntrl;
564    using ::isdigit;
565    using ::islower;
566    using ::isupper;
567    using ::ispunct;
568    using ::isspace;
569    using ::isxdigit;
570    using ::tolower;
571    using ::abs;
572    using ::setlocale;
573 #  ifndef BOOST_NO_WREGEX
574 #     ifndef BOOST_NO_SWPRINTF
575    using ::swprintf;
576 #     endif
577    using ::wcslen;
578    using ::wcscpy;
579    using ::wcscmp;
580    using ::iswalpha;
581    using ::iswcntrl;
582    using ::iswdigit;
583    using ::iswlower;
584    using ::iswpunct;
585    using ::iswspace;
586    using ::iswupper;
587    using ::iswxdigit;
588    using ::towlower;
589    using ::wcsxfrm;
590    using ::wcstombs;
591    using ::mbstowcs;
592 #     if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
593    using ::mbstate_t;
594 #     endif
595 #  endif // BOOST_NO_WREGEX
596    using ::fseek;
597    using ::fread;
598    using ::ftell;
599    using ::fopen;
600    using ::fclose;
601    using ::FILE;
602 #ifdef BOOST_NO_EXCEPTIONS
603    using ::fprintf;
604    using ::abort;
605 #endif
606 }
607
608 #endif
609
610 /*****************************************************************************
611  *
612  *  helper functions pointer_construct/pointer_destroy:
613  *
614  ****************************************************************************/
615
616 #ifdef __cplusplus
617 namespace boost{ namespace re_detail{
618
619 #ifdef BOOST_MSVC
620 #pragma warning (push)
621 #pragma warning (disable : 4100)
622 #endif
623
624 template <class T>
625 inline void pointer_destroy(T* p)
626 { p->~T(); (void)p; }
627
628 #ifdef BOOST_MSVC
629 #pragma warning (pop)
630 #endif
631
632 template <class T>
633 inline void pointer_construct(T* p, const T& t)
634 { new (p) T(t); }
635
636 }} // namespaces
637 #endif
638
639 #endif
640
641
642
643
644
645
646
647