1 /*
2  *
3  * Copyright (c) 1998-2002
4  * 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__) && !defined(__clang__)
26 #  include <boost/regex/config/borland.hpp>
27 #endif
28 #include <boost/version.hpp>
29 
30 /*****************************************************************************
31  *
32  *  Include all the headers we need here:
33  *
34  ****************************************************************************/
35 
36 #ifdef __cplusplus
37 
38 #  ifndef BOOST_REGEX_USER_CONFIG
39 #     define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
40 #  endif
41 
42 #  include BOOST_REGEX_USER_CONFIG
43 
44 #  include <boost/config.hpp>
45 #  include <boost/predef.h>
46 
47 #else
48    /*
49     * C build,
50     * don't include <boost/config.hpp> because that may
51     * do C++ specific things in future...
52     */
53 #  include <stdlib.h>
54 #  include <stddef.h>
55 #  ifdef _MSC_VER
56 #     define BOOST_MSVC _MSC_VER
57 #  endif
58 #endif
59 
60 /*****************************************************************************
61  *
62  *  Boilerplate regex config options:
63  *
64  ****************************************************************************/
65 
66 /* Obsolete macro, use BOOST_VERSION instead: */
67 #define BOOST_RE_VERSION 320
68 
69 /* fix: */
70 #if defined(_UNICODE) && !defined(UNICODE)
71 #define UNICODE
72 #endif
73 
74 
75 /*
76 * Define a macro for the namespace that details are placed in, this includes the Boost
77 * version number to avoid mismatched header and library versions:
78 */
79 #define BOOST_REGEX_DETAIL_NS BOOST_JOIN(re_detail_, BOOST_VERSION)
80 
81 /*
82  * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
83  * masks to be combined, for example:
84  * std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
85  * returns *false*.
86  */
87 #ifdef __GLIBCPP__
88 #  define BOOST_REGEX_BUGGY_CTYPE_FACET
89 #endif
90 
91 /*
92  * Intel C++ before 8.0 ends up with unresolved externals unless we turn off
93  * extern template support:
94  */
95 #if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800)
96 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
97 #endif
98 /*
99  * Visual C++ doesn't support external templates with C++ extensions turned off:
100  */
101 #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
102 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
103 #endif
104  /*
105  * Oracle compiler in C++11 mode doesn't like external templates for some reason:
106  */
107 #ifdef __SUNPRO_CC
108 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
109 #endif
110  /*
111  * Shared regex lib will crash without this, frankly it looks a lot like a gcc bug:
112  */
113 #if defined(__MINGW32__)
114 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
115 #endif
116 /*
117  * Clang fails to export template instances with -fvisibility=hidden, see
118  * https://github.com/boostorg/regex/issues/49
119  */
120 #ifdef __clang__
121 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
122 #endif
123 #ifdef __CYGWIN__
124 /* We get multiply defined symbols without this: */
125 #  define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
126 #endif
127 
128 /*
129  * If there isn't good enough wide character support then there will
130  * be no wide character regular expressions:
131  */
132 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
133 #  if !defined(BOOST_NO_WREGEX)
134 #     define BOOST_NO_WREGEX
135 #  endif
136 #else
137 #  if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
138       /* STLPort on IRIX is misconfigured: <cwctype> does not compile
139        * as a temporary fix include <wctype.h> instead and prevent inclusion
140        * of STLPort version of <cwctype> */
141 #     include <wctype.h>
142 #     define __STLPORT_CWCTYPE
143 #     define _STLP_CWCTYPE
144 #  endif
145 
146 #ifdef __cplusplus
147 #  include <boost/regex/config/cwchar.hpp>
148 #endif
149 
150 #endif
151 
152 /*
153  * If Win32 support has been disabled for boost in general, then
154  * it is for regex in particular:
155  */
156 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
157 #  define BOOST_REGEX_NO_W32
158 #endif
159 
160 /* disable our own file-iterators and mapfiles if we can't
161  * support them: */
162 #if defined(_WIN32)
163 #  if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME
164 #    define BOOST_REGEX_NO_FILEITER
165 #  endif
166 #else /* defined(_WIN32) */
167 #  if !defined(BOOST_HAS_DIRENT_H)
168 #    define BOOST_REGEX_NO_FILEITER
169 #  endif
170 #endif
171 
172 /* backwards compatibitity: */
173 #if defined(BOOST_RE_NO_LIB)
174 #  define BOOST_REGEX_NO_LIB
175 #endif
176 
177 #if defined(__GNUC__) && !defined(_MSC_VER) && (defined(_WIN32) || defined(__CYGWIN__))
178 /* gcc on win32 has problems if you include <windows.h>
179    (sporadically generates bad code). */
180 #  define BOOST_REGEX_NO_W32
181 #endif
182 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
183 #  define BOOST_REGEX_NO_W32
184 #endif
185 
186 /*****************************************************************************
187  *
188  *  Wide character workarounds:
189  *
190  ****************************************************************************/
191 
192 /*
193  * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
194  * code may be built with wchar_t as unsigned short: basically when we're building
195  * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
196  * of the non-inline functions in the library, so that users can still link to the lib,
197  * irrespective of whether their own code is built with /Zc:wchar_t.
198  * Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as
199  * the locale's <unsigned short> facets simply do not compile in that case.
200  * As we default to the C++ locale when compiling for the windows runtime we
201  * skip in this case aswell.
202  */
203 #if defined(__cplusplus) && \
204       (defined(BOOST_MSVC) || defined(__ICL)) && \
205       !defined(BOOST_NO_INTRINSIC_WCHAR_T) && \
206       defined(BOOST_WINDOWS) && \
207       !defined(__SGI_STL_PORT) && \
208       !defined(_STLPORT_VERSION) && \
209       !defined(BOOST_RWSTD_VER) && \
210       ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) && \
211       !BOOST_PLAT_WINDOWS_RUNTIME
212 #  define BOOST_REGEX_HAS_OTHER_WCHAR_T
213 #  ifdef BOOST_MSVC
214 #     pragma warning(push)
215 #     pragma warning(disable : 4251)
216 #if BOOST_MSVC < 1700
217 #     pragma warning(disable : 4231)
218 #endif
219 #     if BOOST_MSVC < 1600
220 #        pragma warning(disable : 4660)
221 #     endif
222 #  endif
223 #  if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
224 #     include <string>
225       extern template class __declspec(dllimport) std::basic_string<unsigned short>;
226 #  endif
227 #  ifdef BOOST_MSVC
228 #     pragma warning(pop)
229 #  endif
230 #endif
231 
232 
233 /*****************************************************************************
234  *
235  *  Set up dll import/export options:
236  *
237  ****************************************************************************/
238 
239 #ifndef BOOST_SYMBOL_EXPORT
240 #  define BOOST_SYMBOL_EXPORT
241 #  define BOOST_SYMBOL_IMPORT
242 #endif
243 
244 #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
245 #  if defined(BOOST_REGEX_SOURCE)
246 #     define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
247 #     define BOOST_REGEX_BUILD_DLL
248 #  else
249 #     define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
250 #  endif
251 #else
252 #  define BOOST_REGEX_DECL
253 #endif
254 
255 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
256 #  define BOOST_LIB_NAME boost_regex
257 #  if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
258 #     define BOOST_DYN_LINK
259 #  endif
260 #  ifdef BOOST_REGEX_DIAG
261 #     define BOOST_LIB_DIAGNOSTIC
262 #  endif
263 #  include <boost/config/auto_link.hpp>
264 #endif
265 
266 /*****************************************************************************
267  *
268  *  Set up function call type:
269  *
270  ****************************************************************************/
271 
272 #if defined(_MSC_VER) && defined(_MSC_EXTENSIONS)
273 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
274 #  define BOOST_REGEX_CALL __cdecl
275 #else
276 #  define BOOST_REGEX_CALL __fastcall
277 #endif
278 #  define BOOST_REGEX_CCALL __cdecl
279 #endif
280 
281 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
282 #if defined(__clang__)
283 #  define BOOST_REGEX_CALL __cdecl
284 #  define BOOST_REGEX_CCALL __cdecl
285 #else
286 #  define BOOST_REGEX_CALL __fastcall
287 #  define BOOST_REGEX_CCALL __stdcall
288 #endif
289 #endif
290 
291 #ifndef BOOST_REGEX_CALL
292 #  define BOOST_REGEX_CALL
293 #endif
294 #ifndef BOOST_REGEX_CCALL
295 #define BOOST_REGEX_CCALL
296 #endif
297 
298 /*****************************************************************************
299  *
300  *  Set up localisation model:
301  *
302  ****************************************************************************/
303 
304 /* backwards compatibility: */
305 #ifdef BOOST_RE_LOCALE_C
306 #  define BOOST_REGEX_USE_C_LOCALE
307 #endif
308 
309 #ifdef BOOST_RE_LOCALE_CPP
310 #  define BOOST_REGEX_USE_CPP_LOCALE
311 #endif
312 
313 #if defined(__CYGWIN__)
314 #  define BOOST_REGEX_USE_C_LOCALE
315 #endif
316 
317 /* use C++ locale when targeting windows store */
318 #if BOOST_PLAT_WINDOWS_RUNTIME
319 #  define BOOST_REGEX_USE_CPP_LOCALE
320 #  define BOOST_REGEX_NO_WIN32_LOCALE
321 #endif
322 
323 /* Win32 defaults to native Win32 locale: */
324 #if defined(_WIN32) && \
325     !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \
326     !defined(BOOST_REGEX_USE_C_LOCALE) && \
327     !defined(BOOST_REGEX_USE_CPP_LOCALE) && \
328     !defined(BOOST_REGEX_NO_W32) && \
329     !defined(BOOST_REGEX_NO_WIN32_LOCALE)
330 #  define BOOST_REGEX_USE_WIN32_LOCALE
331 #endif
332 /* otherwise use C++ locale if supported: */
333 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
334 #  define BOOST_REGEX_USE_CPP_LOCALE
335 #endif
336 /* otherwise use C+ locale: */
337 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
338 #  define BOOST_REGEX_USE_C_LOCALE
339 #endif
340 
341 #ifndef BOOST_REGEX_MAX_STATE_COUNT
342 #  define BOOST_REGEX_MAX_STATE_COUNT 100000000
343 #endif
344 
345 
346 /*****************************************************************************
347  *
348  *  Error Handling for exception free compilers:
349  *
350  ****************************************************************************/
351 
352 #ifdef BOOST_NO_EXCEPTIONS
353 /*
354  * If there are no exceptions then we must report critical-errors
355  * the only way we know how; by terminating.
356  */
357 #include <stdexcept>
358 #include <string>
359 #include <boost/throw_exception.hpp>
360 
361 #  define BOOST_REGEX_NOEH_ASSERT(x)\
362 if(0 == (x))\
363 {\
364    std::string s("Error: critical regex++ failure in: ");\
365    s.append(#x);\
366    std::runtime_error e(s);\
367    boost::throw_exception(e);\
368 }
369 #else
370 /*
371  * With exceptions then error handling is taken care of and
372  * there is no need for these checks:
373  */
374 #  define BOOST_REGEX_NOEH_ASSERT(x)
375 #endif
376 
377 
378 /*****************************************************************************
379  *
380  *  Stack protection under MS Windows:
381  *
382  ****************************************************************************/
383 
384 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
385 #  if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
386         && !(defined(__GNUC__) || defined(__BORLANDC__) && defined(__clang__)) \
387         && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
388         && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
389 #     define BOOST_REGEX_HAS_MS_STACK_GUARD
390 #  endif
391 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
392 #  undef BOOST_REGEX_HAS_MS_STACK_GUARD
393 #endif
394 
395 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
396 
397 namespace boost{
398 namespace BOOST_REGEX_DETAIL_NS{
399 
400 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
401 
402 }
403 }
404 
405 #endif
406 
407 
408 /*****************************************************************************
409  *
410  *  Algorithm selection and configuration:
411  *
412  ****************************************************************************/
413 
414 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
415 #  if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400))
416 #     define BOOST_REGEX_RECURSIVE
417 #  else
418 #     define BOOST_REGEX_NON_RECURSIVE
419 #  endif
420 #endif
421 
422 #ifdef BOOST_REGEX_NON_RECURSIVE
423 #  ifdef BOOST_REGEX_RECURSIVE
424 #     error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
425 #  endif
426 #  ifndef BOOST_REGEX_BLOCKSIZE
427 #     define BOOST_REGEX_BLOCKSIZE 4096
428 #  endif
429 #  if BOOST_REGEX_BLOCKSIZE < 512
430 #     error "BOOST_REGEX_BLOCKSIZE must be at least 512"
431 #  endif
432 #  ifndef BOOST_REGEX_MAX_BLOCKS
433 #     define BOOST_REGEX_MAX_BLOCKS 1024
434 #  endif
435 #  ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
436 #     undef BOOST_REGEX_HAS_MS_STACK_GUARD
437 #  endif
438 #  ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
439 #     define BOOST_REGEX_MAX_CACHE_BLOCKS 16
440 #  endif
441 #endif
442 
443 
444 /*****************************************************************************
445  *
446  *  helper memory allocation functions:
447  *
448  ****************************************************************************/
449 
450 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
451 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
452 
453 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
454 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
455 
456 }} /* namespaces */
457 #endif
458 
459 /*****************************************************************************
460  *
461  *  Diagnostics:
462  *
463  ****************************************************************************/
464 
465 #ifdef BOOST_REGEX_CONFIG_INFO
466 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
467 #endif
468 
469 #if defined(BOOST_REGEX_DIAG)
470 #  pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
471 #  pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
472 #  pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
473 #ifdef BOOST_REGEX_USE_C_LOCALE
474 #  pragma message ("Using C locale in regex traits class")
475 #elif BOOST_REGEX_USE_CPP_LOCALE
476 #  pragma message ("Using C++ locale in regex traits class")
477 #else
478 #  pragma message ("Using Win32 locale in regex traits class")
479 #endif
480 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
481 #  pragma message ("Dynamic linking enabled")
482 #endif
483 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
484 #  pragma message ("Auto-linking disabled")
485 #endif
486 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
487 #  pragma message ("Extern templates disabled")
488 #endif
489 
490 #endif
491 
492 #endif
493 
494 
495 
496 
497