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