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__)
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 
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) || defined(_STLPORT_VERSION))
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 <boost/regex/config/cwchar.hpp>
144 #endif
145 
146 #endif
147 
148 /*
149  * If Win32 support has been disabled for boost in general, then
150  * it is for regex in particular:
151  */
152 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
153 #  define BOOST_REGEX_NO_W32
154 #endif
155 
156 /* disable our own file-iterators and mapfiles if we can't
157  * support them: */
158 #if defined(_WIN32)
159 #  if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME
160 #    define BOOST_REGEX_NO_FILEITER
161 #  endif
162 #else /* defined(_WIN32) */
163 #  if !defined(BOOST_HAS_DIRENT_H)
164 #    define BOOST_REGEX_NO_FILEITER
165 #  endif
166 #endif
167 
168 /* backwards compatibitity: */
169 #if defined(BOOST_RE_NO_LIB)
170 #  define BOOST_REGEX_NO_LIB
171 #endif
172 
173 #if defined(__GNUC__) && !defined(_MSC_VER) && (defined(_WIN32) || defined(__CYGWIN__))
174 /* gcc on win32 has problems if you include <windows.h>
175    (sporadically generates bad code). */
176 #  define BOOST_REGEX_NO_W32
177 #endif
178 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
179 #  define BOOST_REGEX_NO_W32
180 #endif
181 
182 /*****************************************************************************
183  *
184  *  Wide character workarounds:
185  *
186  ****************************************************************************/
187 
188 /*
189  * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
190  * code may be built with wchar_t as unsigned short: basically when we're building
191  * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
192  * of the non-inline functions in the library, so that users can still link to the lib,
193  * irrespective of whether their own code is built with /Zc:wchar_t.
194  * Note that this does NOT WORK with VC10 and VC14 when the C++ locale is in effect as
195  * the locale's <unsigned short> facets simply do not compile in that case.
196  * As we default to the C++ locale when compiling for the windows runtime we
197  * skip in this case aswell.
198  */
199 #if defined(__cplusplus) && \
200       (defined(BOOST_MSVC) || defined(__ICL)) && \
201       !defined(BOOST_NO_INTRINSIC_WCHAR_T) && \
202       defined(BOOST_WINDOWS) && \
203       !defined(__SGI_STL_PORT) && \
204       !defined(_STLPORT_VERSION) && \
205       !defined(BOOST_RWSTD_VER) && \
206       ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) && \
207       !BOOST_PLAT_WINDOWS_RUNTIME
208 #  define BOOST_REGEX_HAS_OTHER_WCHAR_T
209 #  ifdef BOOST_MSVC
210 #     pragma warning(push)
211 #     pragma warning(disable : 4251)
212 #if BOOST_MSVC < 1700
213 #     pragma warning(disable : 4231)
214 #endif
215 #     if BOOST_MSVC < 1600
216 #        pragma warning(disable : 4660)
217 #     endif
218 #  endif
219 #  if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
220 #     include <string>
221       extern template class __declspec(dllimport) std::basic_string<unsigned short>;
222 #  endif
223 #  ifdef BOOST_MSVC
224 #     pragma warning(pop)
225 #  endif
226 #endif
227 
228 
229 /*****************************************************************************
230  *
231  *  Set up dll import/export options:
232  *
233  ****************************************************************************/
234 
235 #ifndef BOOST_SYMBOL_EXPORT
236 #  define BOOST_SYMBOL_EXPORT
237 #  define BOOST_SYMBOL_IMPORT
238 #endif
239 
240 #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
241 #  if defined(BOOST_REGEX_SOURCE)
242 #     define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
243 #     define BOOST_REGEX_BUILD_DLL
244 #  else
245 #     define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
246 #  endif
247 #else
248 #  define BOOST_REGEX_DECL
249 #endif
250 
251 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
252 #  define BOOST_LIB_NAME boost_regex
253 #  if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
254 #     define BOOST_DYN_LINK
255 #  endif
256 #  ifdef BOOST_REGEX_DIAG
257 #     define BOOST_LIB_DIAGNOSTIC
258 #  endif
259 #  include <boost/config/auto_link.hpp>
260 #endif
261 
262 /*****************************************************************************
263  *
264  *  Set up function call type:
265  *
266  ****************************************************************************/
267 
268 #if defined(_MSC_VER) && defined(_MSC_EXTENSIONS)
269 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
270 #  define BOOST_REGEX_CALL __cdecl
271 #else
272 #  define BOOST_REGEX_CALL __fastcall
273 #endif
274 #  define BOOST_REGEX_CCALL __cdecl
275 #endif
276 
277 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
278 #  define BOOST_REGEX_CALL __fastcall
279 #  define BOOST_REGEX_CCALL __stdcall
280 #endif
281 
282 #ifndef BOOST_REGEX_CALL
283 #  define BOOST_REGEX_CALL
284 #endif
285 #ifndef BOOST_REGEX_CCALL
286 #define BOOST_REGEX_CCALL
287 #endif
288 
289 /*****************************************************************************
290  *
291  *  Set up localisation model:
292  *
293  ****************************************************************************/
294 
295 /* backwards compatibility: */
296 #ifdef BOOST_RE_LOCALE_C
297 #  define BOOST_REGEX_USE_C_LOCALE
298 #endif
299 
300 #ifdef BOOST_RE_LOCALE_CPP
301 #  define BOOST_REGEX_USE_CPP_LOCALE
302 #endif
303 
304 #if defined(__CYGWIN__)
305 #  define BOOST_REGEX_USE_C_LOCALE
306 #endif
307 
308 /* use C++ locale when targeting windows store */
309 #if BOOST_PLAT_WINDOWS_RUNTIME
310 #  define BOOST_REGEX_USE_CPP_LOCALE
311 #  define BOOST_REGEX_NO_WIN32_LOCALE
312 #endif
313 
314 /* Win32 defaults to native Win32 locale: */
315 #if defined(_WIN32) && \
316     !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \
317     !defined(BOOST_REGEX_USE_C_LOCALE) && \
318     !defined(BOOST_REGEX_USE_CPP_LOCALE) && \
319     !defined(BOOST_REGEX_NO_W32) && \
320     !defined(BOOST_REGEX_NO_WIN32_LOCALE)
321 #  define BOOST_REGEX_USE_WIN32_LOCALE
322 #endif
323 /* otherwise use C++ locale if supported: */
324 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
325 #  define BOOST_REGEX_USE_CPP_LOCALE
326 #endif
327 /* otherwise use C+ locale: */
328 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
329 #  define BOOST_REGEX_USE_C_LOCALE
330 #endif
331 
332 #ifndef BOOST_REGEX_MAX_STATE_COUNT
333 #  define BOOST_REGEX_MAX_STATE_COUNT 100000000
334 #endif
335 
336 
337 /*****************************************************************************
338  *
339  *  Error Handling for exception free compilers:
340  *
341  ****************************************************************************/
342 
343 #ifdef BOOST_NO_EXCEPTIONS
344 /*
345  * If there are no exceptions then we must report critical-errors
346  * the only way we know how; by terminating.
347  */
348 #include <stdexcept>
349 #include <string>
350 #include <boost/throw_exception.hpp>
351 
352 #  define BOOST_REGEX_NOEH_ASSERT(x)\
353 if(0 == (x))\
354 {\
355    std::string s("Error: critical regex++ failure in: ");\
356    s.append(#x);\
357    std::runtime_error e(s);\
358    boost::throw_exception(e);\
359 }
360 #else
361 /*
362  * With exceptions then error handling is taken care of and
363  * there is no need for these checks:
364  */
365 #  define BOOST_REGEX_NOEH_ASSERT(x)
366 #endif
367 
368 
369 /*****************************************************************************
370  *
371  *  Stack protection under MS Windows:
372  *
373  ****************************************************************************/
374 
375 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
376 #  if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
377         && !defined(__GNUC__) \
378         && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
379         && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
380 #     define BOOST_REGEX_HAS_MS_STACK_GUARD
381 #  endif
382 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
383 #  undef BOOST_REGEX_HAS_MS_STACK_GUARD
384 #endif
385 
386 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
387 
388 namespace boost{
389 namespace BOOST_REGEX_DETAIL_NS{
390 
391 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
392 
393 }
394 }
395 
396 #endif
397 
398 
399 /*****************************************************************************
400  *
401  *  Algorithm selection and configuration:
402  *
403  ****************************************************************************/
404 
405 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
406 #  if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400))
407 #     define BOOST_REGEX_RECURSIVE
408 #  else
409 #     define BOOST_REGEX_NON_RECURSIVE
410 #  endif
411 #endif
412 
413 #ifdef BOOST_REGEX_NON_RECURSIVE
414 #  ifdef BOOST_REGEX_RECURSIVE
415 #     error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
416 #  endif
417 #  ifndef BOOST_REGEX_BLOCKSIZE
418 #     define BOOST_REGEX_BLOCKSIZE 4096
419 #  endif
420 #  if BOOST_REGEX_BLOCKSIZE < 512
421 #     error "BOOST_REGEX_BLOCKSIZE must be at least 512"
422 #  endif
423 #  ifndef BOOST_REGEX_MAX_BLOCKS
424 #     define BOOST_REGEX_MAX_BLOCKS 1024
425 #  endif
426 #  ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
427 #     undef BOOST_REGEX_HAS_MS_STACK_GUARD
428 #  endif
429 #  ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
430 #     define BOOST_REGEX_MAX_CACHE_BLOCKS 16
431 #  endif
432 #endif
433 
434 
435 /*****************************************************************************
436  *
437  *  helper memory allocation functions:
438  *
439  ****************************************************************************/
440 
441 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
442 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
443 
444 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
445 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
446 
447 }} /* namespaces */
448 #endif
449 
450 /*****************************************************************************
451  *
452  *  Diagnostics:
453  *
454  ****************************************************************************/
455 
456 #ifdef BOOST_REGEX_CONFIG_INFO
457 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
458 #endif
459 
460 #if defined(BOOST_REGEX_DIAG)
461 #  pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
462 #  pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
463 #  pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
464 #ifdef BOOST_REGEX_USE_C_LOCALE
465 #  pragma message ("Using C locale in regex traits class")
466 #elif BOOST_REGEX_USE_CPP_LOCALE
467 #  pragma message ("Using C++ locale in regex traits class")
468 #else
469 #  pragma message ("Using Win32 locale in regex traits class")
470 #endif
471 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
472 #  pragma message ("Dynamic linking enabled")
473 #endif
474 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
475 #  pragma message ("Auto-linking disabled")
476 #endif
477 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
478 #  pragma message ("Extern templates disabled")
479 #endif
480 
481 #endif
482 
483 #endif
484 
485 
486 
487 
488