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 #if !((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(BOOST_REGEX_CXX03)) 23 # define BOOST_REGEX_CXX03 24 #endif 25 26 #if defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_CXX03) 27 # define BOOST_REGEX_CXX03 28 #endif 29 30 #if defined(__has_include) 31 #if !defined(BOOST_REGEX_STANDALONE) && !__has_include(<boost/version.hpp>) 32 #define BOOST_REGEX_STANDALONE 33 #endif 34 #endif 35 36 /* 37 * Borland C++ Fix/error check 38 * this has to go *before* we include any std lib headers: 39 */ 40 #if defined(__BORLANDC__) && !defined(__clang__) 41 # include <boost/regex/config/borland.hpp> 42 #endif 43 #ifndef BOOST_REGEX_STANDALONE 44 #include <boost/version.hpp> 45 #endif 46 47 /************************************************************************* 48 * 49 * Asserts: 50 * 51 *************************************************************************/ 52 53 #ifdef BOOST_REGEX_STANDALONE 54 #include <cassert> 55 # define BOOST_REGEX_ASSERT(x) assert(x) 56 #else 57 #include <boost/assert.hpp> 58 # define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x) 59 #endif 60 61 /***************************************************************************** 62 * 63 * Include all the headers we need here: 64 * 65 ****************************************************************************/ 66 67 #ifdef __cplusplus 68 69 # ifndef BOOST_REGEX_USER_CONFIG 70 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp> 71 # endif 72 73 # include BOOST_REGEX_USER_CONFIG 74 75 #ifndef BOOST_REGEX_STANDALONE 76 # include <boost/config.hpp> 77 # include <boost/predef.h> 78 #endif 79 80 #else 81 /* 82 * C build, 83 * don't include <boost/config.hpp> because that may 84 * do C++ specific things in future... 85 */ 86 # include <stdlib.h> 87 # include <stddef.h> 88 # ifdef _MSC_VER 89 # define BOOST_MSVC _MSC_VER 90 # endif 91 #endif 92 93 94 /**************************************************************************** 95 * 96 * Legacy support: 97 * 98 *******************************************************************************/ 99 100 #if defined(BOOST_NO_STD_LOCALE) || defined(BOOST_NO_CXX11_HDR_MUTEX) || defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) \ 101 || defined(BOOST_NO_CXX11_HDR_ATOMIC) || defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_CXX11_SMART_PTR) \ 102 || defined(BOOST_NO_CXX11_STATIC_ASSERT) || defined(BOOST_NO_NOEXCEPT) 103 #ifndef BOOST_REGEX_CXX03 104 # define BOOST_REGEX_CXX03 105 #endif 106 #endif 107 108 /***************************************************************************** 109 * 110 * Boilerplate regex config options: 111 * 112 ****************************************************************************/ 113 114 /* Obsolete macro, use BOOST_VERSION instead: */ 115 #define BOOST_RE_VERSION 500 116 117 /* fix: */ 118 #if defined(_UNICODE) && !defined(UNICODE) 119 #define UNICODE 120 #endif 121 122 #define BOOST_REGEX_JOIN(X, Y) BOOST_REGEX_DO_JOIN(X, Y) 123 #define BOOST_REGEX_DO_JOIN(X, Y) BOOST_REGEX_DO_JOIN2(X,Y) 124 #define BOOST_REGEX_DO_JOIN2(X, Y) X##Y 125 126 #ifdef BOOST_FALLTHROUGH 127 # define BOOST_REGEX_FALLTHROUGH BOOST_FALLTHROUGH 128 #else 129 130 #if defined(__clang__) && (__cplusplus >= 201103L) && defined(__has_warning) 131 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") 132 # define BOOST_REGEX_FALLTHROUGH [[clang::fallthrough]] 133 # endif 134 #endif 135 #if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1800) && (__cplusplus >= 201703) 136 # define BOOST_REGEX_FALLTHROUGH [[fallthrough]] 137 #endif 138 #if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__GNUC__) && (__GNUC__ >= 7) 139 # define BOOST_REGEX_FALLTHROUGH __attribute__((fallthrough)) 140 #endif 141 142 #if !defined(BOOST_REGEX_FALLTHROUGH) 143 # define BOOST_REGEX_FALLTHROUGH 144 #endif 145 #endif 146 147 #ifdef BOOST_NORETURN 148 # define BOOST_REGEX_NORETURN BOOST_NORETURN 149 #else 150 # define BOOST_REGEX_NORETURN 151 #endif 152 153 154 /* 155 * Define a macro for the namespace that details are placed in, this includes the Boost 156 * version number to avoid mismatched header and library versions: 157 */ 158 #define BOOST_REGEX_DETAIL_NS BOOST_REGEX_JOIN(re_detail_, BOOST_RE_VERSION) 159 160 /* 161 * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow 162 * masks to be combined, for example: 163 * std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a'); 164 * returns *false*. 165 */ 166 #if defined(__GLIBCPP__) && defined(BOOST_REGEX_CXX03) 167 # define BOOST_REGEX_BUGGY_CTYPE_FACET 168 #endif 169 170 /* 171 * If there isn't good enough wide character support then there will 172 * be no wide character regular expressions: 173 */ 174 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) 175 # if !defined(BOOST_NO_WREGEX) 176 # define BOOST_NO_WREGEX 177 # endif 178 #else 179 # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) 180 /* STLPort on IRIX is misconfigured: <cwctype> does not compile 181 * as a temporary fix include <wctype.h> instead and prevent inclusion 182 * of STLPort version of <cwctype> */ 183 # include <wctype.h> 184 # define __STLPORT_CWCTYPE 185 # define _STLP_CWCTYPE 186 # endif 187 188 #if defined(__cplusplus) && defined(BOOST_REGEX_CXX03) 189 # include <boost/regex/config/cwchar.hpp> 190 #endif 191 192 #endif 193 194 /* 195 * If Win32 support has been disabled for boost in general, then 196 * it is for regex in particular: 197 */ 198 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32) 199 # define BOOST_REGEX_NO_W32 200 #endif 201 202 /* disable our own file-iterators and mapfiles if we can't 203 * support them: */ 204 #if defined(_WIN32) 205 # if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME 206 # define BOOST_REGEX_NO_FILEITER 207 # endif 208 #else /* defined(_WIN32) */ 209 # if !defined(BOOST_HAS_DIRENT_H) 210 # define BOOST_REGEX_NO_FILEITER 211 # endif 212 #endif 213 214 /* backwards compatibitity: */ 215 #if defined(BOOST_RE_NO_LIB) 216 # define BOOST_REGEX_NO_LIB 217 #endif 218 219 #if defined(__GNUC__) && !defined(_MSC_VER) && (defined(_WIN32) || defined(__CYGWIN__)) 220 /* gcc on win32 has problems if you include <windows.h> 221 (sporadically generates bad code). */ 222 # define BOOST_REGEX_NO_W32 223 #endif 224 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS) 225 # define BOOST_REGEX_NO_W32 226 #endif 227 228 #ifdef BOOST_REGEX_STANDALONE 229 # if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) 230 # define BOOST_REGEX_MSVC _MSC_VER 231 #endif 232 #elif defined(BOOST_MSVC) 233 # define BOOST_REGEX_MSVC BOOST_MSVC 234 #endif 235 236 237 /***************************************************************************** 238 * 239 * Set up dll import/export options: 240 * 241 ****************************************************************************/ 242 243 #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK) && defined(BOOST_SYMBOL_IMPORT) 244 # if defined(BOOST_REGEX_SOURCE) 245 # define BOOST_REGEX_BUILD_DLL 246 # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT 247 # else 248 # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT 249 # endif 250 #else 251 # define BOOST_REGEX_DECL 252 #endif 253 254 #ifdef BOOST_REGEX_CXX03 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 #endif 266 267 /***************************************************************************** 268 * 269 * Set up function call type: 270 * 271 ****************************************************************************/ 272 273 #if defined(_MSC_VER) && defined(_MSC_EXTENSIONS) 274 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL) 275 # define BOOST_REGEX_CALL __cdecl 276 #else 277 # define BOOST_REGEX_CALL __fastcall 278 #endif 279 # define BOOST_REGEX_CCALL __cdecl 280 #endif 281 282 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32) 283 #if defined(__clang__) 284 # define BOOST_REGEX_CALL __cdecl 285 # define BOOST_REGEX_CCALL __cdecl 286 #else 287 # define BOOST_REGEX_CALL __fastcall 288 # define BOOST_REGEX_CCALL __stdcall 289 #endif 290 #endif 291 292 #ifndef BOOST_REGEX_CALL 293 # define BOOST_REGEX_CALL 294 #endif 295 #ifndef BOOST_REGEX_CCALL 296 #define BOOST_REGEX_CCALL 297 #endif 298 299 /***************************************************************************** 300 * 301 * Set up localisation model: 302 * 303 ****************************************************************************/ 304 305 /* backwards compatibility: */ 306 #ifdef BOOST_RE_LOCALE_C 307 # define BOOST_REGEX_USE_C_LOCALE 308 #endif 309 310 #ifdef BOOST_RE_LOCALE_CPP 311 # define BOOST_REGEX_USE_CPP_LOCALE 312 #endif 313 314 #if defined(__CYGWIN__) 315 # define BOOST_REGEX_USE_C_LOCALE 316 #endif 317 318 /* use C++ locale when targeting windows store */ 319 #if BOOST_PLAT_WINDOWS_RUNTIME 320 # define BOOST_REGEX_USE_CPP_LOCALE 321 # define BOOST_REGEX_NO_WIN32_LOCALE 322 #endif 323 324 /* Win32 defaults to native Win32 locale: */ 325 #if defined(_WIN32) && \ 326 !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \ 327 !defined(BOOST_REGEX_USE_C_LOCALE) && \ 328 !defined(BOOST_REGEX_USE_CPP_LOCALE) && \ 329 !defined(BOOST_REGEX_NO_W32) && \ 330 !defined(BOOST_REGEX_NO_WIN32_LOCALE) 331 # define BOOST_REGEX_USE_WIN32_LOCALE 332 #endif 333 /* otherwise use C++ locale if supported: */ 334 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE) 335 # define BOOST_REGEX_USE_CPP_LOCALE 336 #endif 337 /* otherwise use C locale: */ 338 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) 339 # define BOOST_REGEX_USE_C_LOCALE 340 #endif 341 342 #ifndef BOOST_REGEX_MAX_STATE_COUNT 343 # define BOOST_REGEX_MAX_STATE_COUNT 100000000 344 #endif 345 346 347 /***************************************************************************** 348 * 349 * Error Handling for exception free compilers: 350 * 351 ****************************************************************************/ 352 353 #ifdef BOOST_NO_EXCEPTIONS 354 /* 355 * If there are no exceptions then we must report critical-errors 356 * the only way we know how; by terminating. 357 */ 358 #include <stdexcept> 359 #include <string> 360 #include <boost/throw_exception.hpp> 361 362 # define BOOST_REGEX_NOEH_ASSERT(x)\ 363 if(0 == (x))\ 364 {\ 365 std::string s("Error: critical regex++ failure in: ");\ 366 s.append(#x);\ 367 std::runtime_error e(s);\ 368 boost::throw_exception(e);\ 369 } 370 #else 371 /* 372 * With exceptions then error handling is taken care of and 373 * there is no need for these checks: 374 */ 375 # define BOOST_REGEX_NOEH_ASSERT(x) 376 #endif 377 378 379 /***************************************************************************** 380 * 381 * Stack protection under MS Windows: 382 * 383 ****************************************************************************/ 384 385 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3) 386 # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \ 387 && !(defined(__GNUC__) || defined(__BORLANDC__) && defined(__clang__)) \ 388 && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \ 389 && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003)) 390 # define BOOST_REGEX_HAS_MS_STACK_GUARD 391 # endif 392 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD) 393 # undef BOOST_REGEX_HAS_MS_STACK_GUARD 394 #endif 395 396 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD) 397 398 namespace boost{ 399 namespace BOOST_REGEX_DETAIL_NS{ 400 401 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page(); 402 403 } 404 } 405 406 #endif 407 408 409 /***************************************************************************** 410 * 411 * Algorithm selection and configuration. 412 * These options are now obsolete for C++11 and later (regex v5). 413 * 414 ****************************************************************************/ 415 416 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE) 417 # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400)) && defined(BOOST_REGEX_CXX03) 418 # define BOOST_REGEX_RECURSIVE 419 # else 420 # define BOOST_REGEX_NON_RECURSIVE 421 # endif 422 #endif 423 424 #ifdef BOOST_REGEX_NON_RECURSIVE 425 # ifdef BOOST_REGEX_RECURSIVE 426 # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE" 427 # endif 428 # ifndef BOOST_REGEX_BLOCKSIZE 429 # define BOOST_REGEX_BLOCKSIZE 4096 430 # endif 431 # if BOOST_REGEX_BLOCKSIZE < 512 432 # error "BOOST_REGEX_BLOCKSIZE must be at least 512" 433 # endif 434 # ifndef BOOST_REGEX_MAX_BLOCKS 435 # define BOOST_REGEX_MAX_BLOCKS 1024 436 # endif 437 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD 438 # undef BOOST_REGEX_HAS_MS_STACK_GUARD 439 # endif 440 # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS 441 # define BOOST_REGEX_MAX_CACHE_BLOCKS 16 442 # endif 443 #endif 444 445 446 /***************************************************************************** 447 * 448 * Diagnostics: 449 * 450 ****************************************************************************/ 451 452 #ifdef BOOST_REGEX_CONFIG_INFO 453 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info(); 454 #endif 455 456 #if defined(BOOST_REGEX_DIAG) 457 # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL)) 458 # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL)) 459 # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL)) 460 #ifdef BOOST_REGEX_USE_C_LOCALE 461 # pragma message ("Using C locale in regex traits class") 462 #elif BOOST_REGEX_USE_CPP_LOCALE 463 # pragma message ("Using C++ locale in regex traits class") 464 #else 465 # pragma message ("Using Win32 locale in regex traits class") 466 #endif 467 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) 468 # pragma message ("Dynamic linking enabled") 469 #endif 470 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB) 471 # pragma message ("Auto-linking disabled") 472 #endif 473 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES 474 # pragma message ("Extern templates disabled") 475 #endif 476 477 #endif 478 479 #endif 480 481