diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 513a9e10..883aaebd 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -125,7 +125,6 @@ SOURCES = posix_api.cpp regex.cpp regex_debug.cpp - regex_raw_buffer.cpp static_mutex.cpp wide_posix_api.cpp ; diff --git a/include/boost/regex/v4/regex_raw_buffer.hpp b/include/boost/regex/v4/regex_raw_buffer.hpp index f1f4f50a..c73a3e90 100644 --- a/include/boost/regex/v4/regex_raw_buffer.hpp +++ b/include/boost/regex/v4/regex_raw_buffer.hpp @@ -106,7 +106,7 @@ enum{ // this is used by basic_regex for expression storage // -class BOOST_REGEX_DECL raw_storage +class raw_storage { public: typedef std::size_t size_type; @@ -123,8 +123,30 @@ public: ::operator delete(start); } - void BOOST_REGEX_CALL resize(size_type n); - + void BOOST_REGEX_CALL resize(size_type n) + { + size_type newsize = start ? last - start : 1024; + while (newsize < n) + newsize *= 2; + size_type datasize = end - start; + // extend newsize to WORD/DWORD boundary: + newsize = (newsize + padding_mask) & ~(padding_mask); + + // allocate and copy data: + pointer ptr = static_cast(::operator new(newsize)); + BOOST_REGEX_NOEH_ASSERT(ptr) + if (start) + std::memcpy(ptr, start, datasize); + + // get rid of old buffer: + ::operator delete(start); + + // and set up pointers: + start = ptr; + end = ptr + datasize; + last = ptr + newsize; + } + void* BOOST_REGEX_CALL extend(size_type n) { if(size_type(last - end) < n) @@ -134,7 +156,16 @@ public: return result; } - void* BOOST_REGEX_CALL insert(size_type pos, size_type n); + void* BOOST_REGEX_CALL insert(size_type pos, size_type n) + { + BOOST_ASSERT(pos <= size_type(end - start)); + if (size_type(last - end) < n) + resize(n + (end - start)); + void* result = start + pos; + std::memmove(start + pos + n, start + pos, (end - start) - pos); + end += n; + return result; + } size_type BOOST_REGEX_CALL size() { diff --git a/include/boost/regex/v5/regex_raw_buffer.hpp b/include/boost/regex/v5/regex_raw_buffer.hpp index f1f4f50a..c73a3e90 100644 --- a/include/boost/regex/v5/regex_raw_buffer.hpp +++ b/include/boost/regex/v5/regex_raw_buffer.hpp @@ -106,7 +106,7 @@ enum{ // this is used by basic_regex for expression storage // -class BOOST_REGEX_DECL raw_storage +class raw_storage { public: typedef std::size_t size_type; @@ -123,8 +123,30 @@ public: ::operator delete(start); } - void BOOST_REGEX_CALL resize(size_type n); - + void BOOST_REGEX_CALL resize(size_type n) + { + size_type newsize = start ? last - start : 1024; + while (newsize < n) + newsize *= 2; + size_type datasize = end - start; + // extend newsize to WORD/DWORD boundary: + newsize = (newsize + padding_mask) & ~(padding_mask); + + // allocate and copy data: + pointer ptr = static_cast(::operator new(newsize)); + BOOST_REGEX_NOEH_ASSERT(ptr) + if (start) + std::memcpy(ptr, start, datasize); + + // get rid of old buffer: + ::operator delete(start); + + // and set up pointers: + start = ptr; + end = ptr + datasize; + last = ptr + newsize; + } + void* BOOST_REGEX_CALL extend(size_type n) { if(size_type(last - end) < n) @@ -134,7 +156,16 @@ public: return result; } - void* BOOST_REGEX_CALL insert(size_type pos, size_type n); + void* BOOST_REGEX_CALL insert(size_type pos, size_type n) + { + BOOST_ASSERT(pos <= size_type(end - start)); + if (size_type(last - end) < n) + resize(n + (end - start)); + void* result = start + pos; + std::memmove(start + pos + n, start + pos, (end - start) - pos); + end += n; + return result; + } size_type BOOST_REGEX_CALL size() { diff --git a/src/regex_raw_buffer.cpp b/src/regex_raw_buffer.cpp deleted file mode 100644 index bb492297..00000000 --- a/src/regex_raw_buffer.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file - * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - * - */ - - /* - * LOCATION: see http://www.boost.org for most recent version. - * FILE regex_raw_buffer.cpp - * VERSION see - * DESCRIPTION: Member functions for class raw_storage. - */ - - -#define BOOST_REGEX_SOURCE -#include -#include -#include -#include -#include - -#if defined(BOOST_NO_STDC_NAMESPACE) -namespace std{ - using ::memcpy; - using ::memmove; -} -#endif - - -namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ - -void BOOST_REGEX_CALL raw_storage::resize(size_type n) -{ - size_type newsize = start ? last - start : 1024; - while(newsize < n) - newsize *= 2; - size_type datasize = end - start; - // extend newsize to WORD/DWORD boundary: - newsize = (newsize + padding_mask) & ~(padding_mask); - - // allocate and copy data: - pointer ptr = static_cast(::operator new(newsize)); - BOOST_REGEX_NOEH_ASSERT(ptr) - if(start) - std::memcpy(ptr, start, datasize); - - // get rid of old buffer: - ::operator delete(start); - - // and set up pointers: - start = ptr; - end = ptr + datasize; - last = ptr + newsize; -} - -void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n) -{ - BOOST_ASSERT(pos <= size_type(end - start)); - if(size_type(last - end) < n) - resize(n + (end - start)); - void* result = start + pos; - std::memmove(start + pos + n, start + pos, (end - start) - pos); - end += n; - return result; -} - -}} // namespaces diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6efd169a..d461c7f5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -64,7 +64,6 @@ lib boost_regex_recursive : ../src/posix_api.cpp ../src/regex.cpp ../src/regex_debug.cpp - ../src/regex_raw_buffer.cpp ../src/static_mutex.cpp ../src/wide_posix_api.cpp ../build//icu_options diff --git a/test/captures/Jamfile.v2 b/test/captures/Jamfile.v2 index 7c1850eb..3b0ed7ed 100644 --- a/test/captures/Jamfile.v2 +++ b/test/captures/Jamfile.v2 @@ -11,7 +11,6 @@ EX_SOURCES = posix_api.cpp regex.cpp regex_debug.cpp - regex_raw_buffer.cpp static_mutex.cpp wide_posix_api.cpp ; diff --git a/test/noeh_test/Jamfile.v2 b/test/noeh_test/Jamfile.v2 index b2f4d8fa..49e57d59 100644 --- a/test/noeh_test/Jamfile.v2 +++ b/test/noeh_test/Jamfile.v2 @@ -27,7 +27,6 @@ lib boost_regex_noeh : ../../src/posix_api.cpp ../../src/regex.cpp ../../src/regex_debug.cpp - ../../src/regex_raw_buffer.cpp ../../src/static_mutex.cpp ../../src/wide_posix_api.cpp ../../build//icu_options diff --git a/test/test_consolidated.cpp b/test/test_consolidated.cpp index 97415124..d5415f2b 100644 --- a/test/test_consolidated.cpp +++ b/test/test_consolidated.cpp @@ -13,6 +13,5 @@ #include #include #include -#include #include #include