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