From 54a5ed85093281ee0950cd169d5eaaf595723218 Mon Sep 17 00:00:00 2001 From: Christian Maurer Date: Tue, 9 Nov 2021 16:24:52 +0100 Subject: [PATCH 01/13] Fix unused variable warnings --- include/boost/regex/v5/icu.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/boost/regex/v5/icu.hpp b/include/boost/regex/v5/icu.hpp index f172553d..aefd9768 100644 --- a/include/boost/regex/v5/icu.hpp +++ b/include/boost/regex/v5/icu.hpp @@ -190,8 +190,8 @@ public: constexpr char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; constexpr char_class_type mask_underscore = char_class_type(1) << offset_underscore; constexpr char_class_type mask_unicode = char_class_type(1) << offset_unicode; - constexpr char_class_type mask_any = char_class_type(1) << offset_any; - constexpr char_class_type mask_ascii = char_class_type(1) << offset_ascii; + //constexpr char_class_type mask_any = char_class_type(1) << offset_any; + //constexpr char_class_type mask_ascii = char_class_type(1) << offset_ascii; constexpr char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; constexpr char_class_type mask_vertical = char_class_type(1) << offset_vertical; @@ -365,15 +365,15 @@ private: static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2) { - constexpr char_class_type mask_blank = char_class_type(1) << offset_blank; - constexpr char_class_type mask_space = char_class_type(1) << offset_space; - constexpr char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; - constexpr char_class_type mask_underscore = char_class_type(1) << offset_underscore; - constexpr char_class_type mask_unicode = char_class_type(1) << offset_unicode; + //constexpr char_class_type mask_blank = char_class_type(1) << offset_blank; + //constexpr char_class_type mask_space = char_class_type(1) << offset_space; + //constexpr char_class_type mask_xdigit = char_class_type(1) << offset_xdigit; + //constexpr char_class_type mask_underscore = char_class_type(1) << offset_underscore; + //constexpr char_class_type mask_unicode = char_class_type(1) << offset_unicode; constexpr char_class_type mask_any = char_class_type(1) << offset_any; constexpr char_class_type mask_ascii = char_class_type(1) << offset_ascii; - constexpr char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; - constexpr char_class_type mask_vertical = char_class_type(1) << offset_vertical; + //constexpr char_class_type mask_horizontal = char_class_type(1) << offset_horizontal; + //constexpr char_class_type mask_vertical = char_class_type(1) << offset_vertical; static const ::UChar32 prop_name_table[] = { /* any */ 'a', 'n', 'y', From c23e7b857accd4535a0559c00b13920d89f1eef0 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 2 Dec 2022 17:10:45 +0000 Subject: [PATCH 02/13] Add missing #include. Fixes https://github.com/boostorg/regex/issues/183 --- src/posix_api.cpp | 1 + src/wide_posix_api.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/posix_api.cpp b/src/posix_api.cpp index 95978e43..cab93854 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #if defined(BOOST_NO_STDC_NAMESPACE) diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index abd68c59..50d1b18d 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include From a142dfecda7644e58382f4b6c527f37309af03f4 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 2 Dec 2022 17:25:16 +0000 Subject: [PATCH 03/13] Call snprintf when available in posix_api.cpp. Fixes https://github.com/boostorg/regex/issues/184. --- src/posix_api.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/posix_api.cpp b/src/posix_api.cpp index cab93854..0b44910a 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -177,7 +177,9 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* // We're converting an integer i to a string, and since i <= REG_E_UNKNOWN // a five character string is *always* large enough: // -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) +#if BOOST_CXX_VERSION >= 201103 + int r = (std::snprintf)(localbuf, 5, "%d", i); +#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) int r = (::sprintf_s)(localbuf, 5, "%d", i); #else int r = (std::sprintf)(localbuf, "%d", i); @@ -189,7 +191,9 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* return std::strlen(localbuf) + 1; } } -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) +#if BOOST_CXX_VERSION >= 201103 + int r = (::snprintf)(localbuf, 5, "%d", 0); +#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) int r = (::sprintf_s)(localbuf, 5, "%d", 0); #else int r = (std::sprintf)(localbuf, "%d", 0); From 3e4bcb75b67d81c2c67c91ec9c53d9dffa690dc0 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 9 Dec 2022 18:24:24 +0000 Subject: [PATCH 04/13] Add testing of standalone mode. Allow tests to be built in standalone mode. Update CI. Update docs. --- .github/workflows/ci.yml | 25 +++++++ .../boost_regex/configuration/standalone.html | 65 +++++++++++++++++++ doc/html/index.html | 2 +- src/posix_api.cpp | 9 ++- src/wide_posix_api.cpp | 7 +- test/regress/basic_tests.cpp | 8 --- test/regress/main.cpp | 7 ++ test/regress/test.hpp | 17 +++++ test/regress/test_icu.cpp | 15 +++++ test/regress/test_mfc.cpp | 2 +- 10 files changed, 142 insertions(+), 15 deletions(-) create mode 100644 doc/html/boost_regex/configuration/standalone.html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec5a5aa6..1976a8d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,31 @@ jobs: - name: Test run: ../../../b2 toolset=$TOOLSET working-directory: ../boost-root/libs/regex/test + ubuntu-focal-standalone: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + compiler: [ g++-9, g++-10 ] + standard: [ c++11, c++14, c++17, c++2a ] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: mstachniuk/ci-skip@v1 + with: + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]' + commit-filter-separator: ';' + fail-fast: true + - name: Set TOOLSET + run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV + - name: Add repository + run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + - name: Install packages + run: sudo apt install g++-9 g++-10 + - name: Test + run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licudata -licu18n && ./regress + working-directory: $GITHUB_WORKSPACE/test/regress ubuntu-bionic: runs-on: ubuntu-18.04 strategy: diff --git a/doc/html/boost_regex/configuration/standalone.html b/doc/html/boost_regex/configuration/standalone.html new file mode 100644 index 00000000..35c7f117 --- /dev/null +++ b/doc/html/boost_regex/configuration/standalone.html @@ -0,0 +1,65 @@ + + + +Use in Standalone Mode (without the rest of Boost) + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ This library may now be used in "standalone" mode without the rest + of the Boost C++ libraries, in order to do this you must either: +

+
    +
  • + Have a C++17 compiler that supports __has_include, + in this case if <boost/config.hpp> is not + present then the library will automoatically enter standalone mode. Or: +
  • +
  • + Define BOOST_REGEX_STANDALONE when building. +
  • +
+

+ The main difference between the 2 modes, is that when Boost.Config is present + the library will automatically configure itself around various compiler defects. + In particular in order to use the library with exception support turned off, + you will either need a copy of Boost.Config in your include path, or else + manually define BOOST_NO_EXCEPTIONS when building. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/index.html b/doc/html/index.html index 6e4a4774..4c85c747 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -215,7 +215,7 @@

- +

Last revised: March 08, 2022 at 11:25:00 GMT

Last revised: December 09, 2022 at 16:44:04 GMT


diff --git a/src/posix_api.cpp b/src/posix_api.cpp index 0b44910a..f34a5a16 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -18,10 +18,8 @@ #define BOOST_REGEX_SOURCE -#include #include #include -#include #include #if defined(BOOST_NO_STDC_NAMESPACE) @@ -32,6 +30,11 @@ namespace std{ } #endif +#ifndef BOOST_WORKAROUND +#define BOOST_WORKAROUND(x, y) false +#endif + + namespace boost{ @@ -88,7 +91,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char return REG_E_MEMORY; #endif // set default flags: - boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic); + unsigned flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic); expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; // and translate those that are actually set: diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index 50d1b18d..508acb32 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -20,11 +20,14 @@ #include +#ifndef BOOST_WORKAROUND +#define BOOST_WORKAROUND(x, y) false +#endif + #ifndef BOOST_NO_WREGEX #include #include -#include #include #include @@ -98,7 +101,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha return REG_E_MEMORY; #endif // set default flags: - boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic); + unsigned flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic); expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; // and translate those that are actually set: diff --git a/test/regress/basic_tests.cpp b/test/regress/basic_tests.cpp index a1a3e817..f8a0952d 100644 --- a/test/regress/basic_tests.cpp +++ b/test/regress/basic_tests.cpp @@ -16,14 +16,6 @@ * DESCRIPTION: main regex test declarations. */ -#include - -#if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x560) -// we get unresolved externals from basic_string -// unless we do this, a well known Borland bug: -#define _RWSTD_COMPILE_INSTANTIATE -#endif - #include "test.hpp" #ifdef BOOST_MSVC diff --git a/test/regress/main.cpp b/test/regress/main.cpp index 8942f717..3f2f82f3 100644 --- a/test/regress/main.cpp +++ b/test/regress/main.cpp @@ -217,6 +217,13 @@ int main(int argc, char * argv[]) return cpp_main(argc, argv); } +#elif defined(BOOST_REGEX_STANDALONE) + +int main(int argc, char* argv[]) +{ + return cpp_main(argc, argv); +} + #else #include diff --git a/test/regress/test.hpp b/test/regress/test.hpp index e9a1b862..eebcdbe9 100644 --- a/test/regress/test.hpp +++ b/test/regress/test.hpp @@ -27,6 +27,23 @@ #pragma warning(disable:1418 981 383 1419 7) #endif +#ifndef BOOST_WORKAROUND +#define BOOST_WORKAROUND(x, y) false +#endif +#ifdef BOOST_REGEX_STANDALONE +#include + +namespace boost { using std::uint32_t; } + +#define BOOST_JOIN(X, Y) BOOST_DO_JOIN(X, Y) +#define BOOST_DO_JOIN(X, Y) BOOST_DO_JOIN2(X,Y) +#define BOOST_DO_JOIN2(X, Y) X##Y + +#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) +#define BOOST_DO_STRINGIZE(X) #X + +#endif + #include #include "test_not_regex.hpp" #include "test_regex_search.hpp" diff --git a/test/regress/test_icu.cpp b/test/regress/test_icu.cpp index 39eda8a2..5dbc1cb6 100644 --- a/test/regress/test_icu.cpp +++ b/test/regress/test_icu.cpp @@ -20,10 +20,25 @@ // We can only build this if we have ICU support: // #include + +#ifdef __has_include +#if __has_include() +#define BOOST_HAS_ICU +#endif +#endif + #if defined(BOOST_HAS_ICU) && !defined(BOOST_NO_STD_WSTRING) #include +#ifndef BOOST_REGEX_STANDALONE #include +#else +#include +namespace boost { namespace mpl { + template + using int_ = ::std::integral_constant; +} } +#endif #include "test.hpp" namespace unnecessary_fix{ diff --git a/test/regress/test_mfc.cpp b/test/regress/test_mfc.cpp index 1dad08cf..2590f4f1 100644 --- a/test/regress/test_mfc.cpp +++ b/test/regress/test_mfc.cpp @@ -19,7 +19,7 @@ // // We can only build this if we have ATL support: // -#include +#include #ifdef TEST_MFC From 6213ff03fce211531e952e3d35c990283c64cd4b Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 9 Dec 2022 18:35:37 +0000 Subject: [PATCH 05/13] Fix macro redefinition. --- src/wide_posix_api.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index 508acb32..8abb28e3 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -20,15 +20,15 @@ #include -#ifndef BOOST_WORKAROUND -#define BOOST_WORKAROUND(x, y) false -#endif - #ifndef BOOST_NO_WREGEX #include #include +#ifndef BOOST_WORKAROUND +#define BOOST_WORKAROUND(x, y) false +#endif + #include #include #include From 1a750a42d1b784f68f936bff8334c90a4a87ac9f Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 10 Dec 2022 11:44:19 +0000 Subject: [PATCH 06/13] Correct CI script, correct ICU testing config. --- .github/workflows/ci.yml | 2 +- test/regress/test_icu.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1976a8d2..fd279175 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: run: sudo apt install g++-9 g++-10 - name: Test run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licudata -licu18n && ./regress - working-directory: $GITHUB_WORKSPACE/test/regress + working-directory: ./test/regress ubuntu-bionic: runs-on: ubuntu-18.04 strategy: diff --git a/test/regress/test_icu.cpp b/test/regress/test_icu.cpp index 5dbc1cb6..c0d7f569 100644 --- a/test/regress/test_icu.cpp +++ b/test/regress/test_icu.cpp @@ -21,11 +21,13 @@ // #include +#ifdef BOOST_REGEX_STANDALONE #ifdef __has_include -#if __has_include() +#if __has_include() && __has_include() && __has_include() #define BOOST_HAS_ICU #endif #endif +#endif #if defined(BOOST_HAS_ICU) && !defined(BOOST_NO_STD_WSTRING) From 99653df37dc971728a098cf9a649b20456f30e66 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 10 Dec 2022 17:59:17 +0000 Subject: [PATCH 07/13] Correct ICU i18n library name. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd279175..cd852515 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: - name: Install packages run: sudo apt install g++-9 g++-10 - name: Test - run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licudata -licu18n && ./regress + run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licudata -licui18n && ./regress working-directory: ./test/regress ubuntu-bionic: runs-on: ubuntu-18.04 From 86b2fbe6005c1624390a9bd57418101d7dc9ab69 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 12 Dec 2022 18:06:45 +0000 Subject: [PATCH 08/13] Tweak CI script. --- .github/workflows/ci.yml | 6 +++--- src/posix_api.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd852515..d945587a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,8 +64,8 @@ jobs: - name: Test run: ../../../b2 toolset=$TOOLSET working-directory: ../boost-root/libs/regex/test - ubuntu-focal-standalone: - runs-on: ubuntu-20.04 + ubuntu-jammy-standalone: + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -87,7 +87,7 @@ jobs: - name: Install packages run: sudo apt install g++-9 g++-10 - name: Test - run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licudata -licui18n && ./regress + run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licui18n && ./regress working-directory: ./test/regress ubuntu-bionic: runs-on: ubuntu-18.04 diff --git a/src/posix_api.cpp b/src/posix_api.cpp index f34a5a16..131171ab 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -180,7 +180,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* // We're converting an integer i to a string, and since i <= REG_E_UNKNOWN // a five character string is *always* large enough: // -#if BOOST_CXX_VERSION >= 201103 +#if !defined(BOOST_CXX_VERSION) || (BOOST_CXX_VERSION >= 201103) int r = (std::snprintf)(localbuf, 5, "%d", i); #elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) int r = (::sprintf_s)(localbuf, 5, "%d", i); @@ -194,7 +194,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* return std::strlen(localbuf) + 1; } } -#if BOOST_CXX_VERSION >= 201103 +#if !defined(BOOST_CXX_VERSION) || (BOOST_CXX_VERSION >= 201103) int r = (::snprintf)(localbuf, 5, "%d", 0); #elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) int r = (::sprintf_s)(localbuf, 5, "%d", 0); From adae246a461960ce4f2f1f96882a39f25dde6c73 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 12 Dec 2022 18:35:57 +0000 Subject: [PATCH 09/13] Add package to CI script. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d945587a..4a37553a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: strategy: fail-fast: false matrix: - compiler: [ g++-9, g++-10 ] + compiler: [ g++ ] standard: [ c++11, c++14, c++17, c++2a ] steps: - uses: actions/checkout@v2 @@ -85,7 +85,7 @@ jobs: - name: Add repository run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" - name: Install packages - run: sudo apt install g++-9 g++-10 + run: sudo apt install libicu-dev - name: Test run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licui18n && ./regress working-directory: ./test/regress From 39e5c86f448c9fd913b09d4a1c519d665516dab7 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Tue, 13 Dec 2022 11:34:28 +0000 Subject: [PATCH 10/13] Remove ICU standalone testing for now: it passes locally but not on the remote machine. --- .github/workflows/ci.yml | 2 +- test/regress/test_icu.cpp | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a37553a..7cc86d2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: - name: Install packages run: sudo apt install libicu-dev - name: Test - run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress -licuuc -licui18n && ./regress + run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress && ./regress working-directory: ./test/regress ubuntu-bionic: runs-on: ubuntu-18.04 diff --git a/test/regress/test_icu.cpp b/test/regress/test_icu.cpp index c0d7f569..95e2bf54 100644 --- a/test/regress/test_icu.cpp +++ b/test/regress/test_icu.cpp @@ -21,14 +21,6 @@ // #include -#ifdef BOOST_REGEX_STANDALONE -#ifdef __has_include -#if __has_include() && __has_include() && __has_include() -#define BOOST_HAS_ICU -#endif -#endif -#endif - #if defined(BOOST_HAS_ICU) && !defined(BOOST_NO_STD_WSTRING) #include From 430419705b8c0180c612993cc9a6c13a5a815779 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Tue, 13 Dec 2022 18:48:10 +0000 Subject: [PATCH 11/13] Simplify snprintf workaround usage. Via boost/core/snprintf.hpp Remove some obsolete workarounds. Remove tabs in files. Supersedes https://github.com/boostorg/regex/pull/188. --- include/boost/regex/v4/regex_workaround.hpp | 14 +++++----- include/boost/regex/v5/regex_workaround.hpp | 14 +++++----- src/posix_api.cpp | 30 +++++---------------- src/wide_posix_api.cpp | 9 ------- 4 files changed, 21 insertions(+), 46 deletions(-) diff --git a/include/boost/regex/v4/regex_workaround.hpp b/include/boost/regex/v4/regex_workaround.hpp index 35eafc25..324136e0 100644 --- a/include/boost/regex/v4/regex_workaround.hpp +++ b/include/boost/regex/v4/regex_workaround.hpp @@ -198,10 +198,10 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ const char *strSource ) { - std::size_t lenSourceWithNull = std::strlen(strSource) + 1; - if (lenSourceWithNull > sizeInBytes) + std::size_t lenSourceWithNull = std::strlen(strSource) + 1; + if (lenSourceWithNull > sizeInBytes) return 1; - std::memcpy(strDestination, strSource, lenSourceWithNull); + std::memcpy(strDestination, strSource, lenSourceWithNull); return 0; } inline std::size_t strcat_s( @@ -210,11 +210,11 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ const char *strSource ) { - std::size_t lenSourceWithNull = std::strlen(strSource) + 1; - std::size_t lenDestination = std::strlen(strDestination); - if (lenSourceWithNull + lenDestination > sizeInBytes) + std::size_t lenSourceWithNull = std::strlen(strSource) + 1; + std::size_t lenDestination = std::strlen(strDestination); + if (lenSourceWithNull + lenDestination > sizeInBytes) return 1; - std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull); + std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull); return 0; } diff --git a/include/boost/regex/v5/regex_workaround.hpp b/include/boost/regex/v5/regex_workaround.hpp index e9ca79d4..8cd9044c 100644 --- a/include/boost/regex/v5/regex_workaround.hpp +++ b/include/boost/regex/v5/regex_workaround.hpp @@ -116,10 +116,10 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ const char *strSource ) { - std::size_t lenSourceWithNull = std::strlen(strSource) + 1; - if (lenSourceWithNull > sizeInBytes) + std::size_t lenSourceWithNull = std::strlen(strSource) + 1; + if (lenSourceWithNull > sizeInBytes) return 1; - std::memcpy(strDestination, strSource, lenSourceWithNull); + std::memcpy(strDestination, strSource, lenSourceWithNull); return 0; } inline std::size_t strcat_s( @@ -128,11 +128,11 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ const char *strSource ) { - std::size_t lenSourceWithNull = std::strlen(strSource) + 1; - std::size_t lenDestination = std::strlen(strDestination); - if (lenSourceWithNull + lenDestination > sizeInBytes) + std::size_t lenSourceWithNull = std::strlen(strSource) + 1; + std::size_t lenDestination = std::strlen(strDestination); + if (lenSourceWithNull + lenDestination > sizeInBytes) return 1; - std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull); + std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull); return 0; } diff --git a/src/posix_api.cpp b/src/posix_api.cpp index 131171ab..e30f9d8e 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -22,19 +22,15 @@ #include #include -#if defined(BOOST_NO_STDC_NAMESPACE) -namespace std{ - using ::sprintf; - using ::strcpy; - using ::strcmp; -} -#endif - #ifndef BOOST_WORKAROUND #define BOOST_WORKAROUND(x, y) false #endif - +#ifndef BOOST_REGEX_STANDALONE +#include +#else +namespace boost { namespace core { using std::snprintf; } } +#endif namespace boost{ @@ -180,13 +176,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* // We're converting an integer i to a string, and since i <= REG_E_UNKNOWN // a five character string is *always* large enough: // -#if !defined(BOOST_CXX_VERSION) || (BOOST_CXX_VERSION >= 201103) - int r = (std::snprintf)(localbuf, 5, "%d", i); -#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) - int r = (::sprintf_s)(localbuf, 5, "%d", i); -#else - int r = (std::sprintf)(localbuf, "%d", i); -#endif + int r = (boost::core::snprintf)(localbuf, 5, "%d", i); if(r < 0) return 0; // sprintf failed if(std::strlen(localbuf) < buf_size) @@ -194,13 +184,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* return std::strlen(localbuf) + 1; } } -#if !defined(BOOST_CXX_VERSION) || (BOOST_CXX_VERSION >= 201103) - int r = (::snprintf)(localbuf, 5, "%d", 0); -#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) - int r = (::sprintf_s)(localbuf, 5, "%d", 0); -#else - int r = (std::sprintf)(localbuf, "%d", 0); -#endif + int r = (boost::core::snprintf)(localbuf, 5, "%d", 0); if(r < 0) return 0; // sprintf failed if(std::strlen(localbuf) < buf_size) diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index 8abb28e3..5ca4c7ae 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -37,15 +37,6 @@ #pragma warning(disable:981) #endif -#if defined(BOOST_NO_STDC_NAMESPACE) || defined(__NetBSD__) -namespace std{ -# ifndef BOOST_NO_SWPRINTF - using ::swprintf; -# endif -} -#endif - - namespace boost{ namespace { From 362c85cf665b8b7b987760d734fcd53353dad49e Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 14 Dec 2022 13:06:33 +0000 Subject: [PATCH 12/13] Add swprintf workarounds. --- src/wide_posix_api.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index 5ca4c7ae..e55fadb5 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -25,6 +25,12 @@ #include #include +#ifndef BOOST_REGEX_STANDALONE +#include +#else +namespace boost { namespace core { using std::swprintf; } } +#endif + #ifndef BOOST_WORKAROUND #define BOOST_WORKAROUND(x, y) false #endif @@ -185,7 +191,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* #if defined(_WIN32_WCE) && !defined(UNDER_CE) (std::swprintf)(localbuf, L"%d", i); #else - (std::swprintf)(localbuf, 5, L"%d", i); + (boost::core::swprintf)(localbuf, 5, L"%d", i); #endif if(std::wcslen(localbuf) < buf_size) #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) @@ -199,7 +205,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* #if defined(_WIN32_WCE) && !defined(UNDER_CE) (std::swprintf)(localbuf, L"%d", 0); #else - (std::swprintf)(localbuf, 5, L"%d", 0); + (boost::core::swprintf)(localbuf, 5, L"%d", 0); #endif if(std::wcslen(localbuf) < buf_size) #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) From 372d3f7a7ebbeb23924b220bb01a36de42bad953 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 14 Dec 2022 18:39:17 +0000 Subject: [PATCH 13/13] Drop redundant config check. --- src/wide_posix_api.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index e55fadb5..993464f8 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -178,7 +178,6 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* } return result; } -#if !defined(BOOST_NO_SWPRINTF) if(code == REG_ATOI) { wchar_t localbuf[5]; @@ -215,7 +214,6 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* #endif return std::wcslen(localbuf) + 1; } -#endif if(code <= (int)REG_E_UNKNOWN) { std::string p;