forked from boostorg/regex
Make regex_raw_buffer header only.
This commit is contained in:
@ -125,7 +125,6 @@ SOURCES =
|
|||||||
posix_api.cpp
|
posix_api.cpp
|
||||||
regex.cpp
|
regex.cpp
|
||||||
regex_debug.cpp
|
regex_debug.cpp
|
||||||
regex_raw_buffer.cpp
|
|
||||||
static_mutex.cpp
|
static_mutex.cpp
|
||||||
wide_posix_api.cpp
|
wide_posix_api.cpp
|
||||||
;
|
;
|
||||||
|
@ -106,7 +106,7 @@ enum{
|
|||||||
// this is used by basic_regex for expression storage
|
// this is used by basic_regex for expression storage
|
||||||
//
|
//
|
||||||
|
|
||||||
class BOOST_REGEX_DECL raw_storage
|
class raw_storage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::size_t size_type;
|
typedef std::size_t size_type;
|
||||||
@ -123,7 +123,29 @@ public:
|
|||||||
::operator delete(start);
|
::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<pointer>(::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)
|
void* BOOST_REGEX_CALL extend(size_type n)
|
||||||
{
|
{
|
||||||
@ -134,7 +156,16 @@ public:
|
|||||||
return result;
|
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()
|
size_type BOOST_REGEX_CALL size()
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ enum{
|
|||||||
// this is used by basic_regex for expression storage
|
// this is used by basic_regex for expression storage
|
||||||
//
|
//
|
||||||
|
|
||||||
class BOOST_REGEX_DECL raw_storage
|
class raw_storage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::size_t size_type;
|
typedef std::size_t size_type;
|
||||||
@ -123,7 +123,29 @@ public:
|
|||||||
::operator delete(start);
|
::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<pointer>(::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)
|
void* BOOST_REGEX_CALL extend(size_type n)
|
||||||
{
|
{
|
||||||
@ -134,7 +156,16 @@ public:
|
|||||||
return result;
|
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()
|
size_type BOOST_REGEX_CALL size()
|
||||||
{
|
{
|
||||||
|
@ -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 <boost/version.hpp>
|
|
||||||
* DESCRIPTION: Member functions for class raw_storage.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_REGEX_SOURCE
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <memory>
|
|
||||||
#include <cstring>
|
|
||||||
#include <boost/assert.hpp>
|
|
||||||
#include <boost/regex/v4/regex_raw_buffer.hpp>
|
|
||||||
|
|
||||||
#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<pointer>(::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
|
|
@ -64,7 +64,6 @@ lib boost_regex_recursive :
|
|||||||
../src/posix_api.cpp
|
../src/posix_api.cpp
|
||||||
../src/regex.cpp
|
../src/regex.cpp
|
||||||
../src/regex_debug.cpp
|
../src/regex_debug.cpp
|
||||||
../src/regex_raw_buffer.cpp
|
|
||||||
../src/static_mutex.cpp
|
../src/static_mutex.cpp
|
||||||
../src/wide_posix_api.cpp
|
../src/wide_posix_api.cpp
|
||||||
../build//icu_options
|
../build//icu_options
|
||||||
|
@ -11,7 +11,6 @@ EX_SOURCES =
|
|||||||
posix_api.cpp
|
posix_api.cpp
|
||||||
regex.cpp
|
regex.cpp
|
||||||
regex_debug.cpp
|
regex_debug.cpp
|
||||||
regex_raw_buffer.cpp
|
|
||||||
static_mutex.cpp
|
static_mutex.cpp
|
||||||
wide_posix_api.cpp ;
|
wide_posix_api.cpp ;
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ lib boost_regex_noeh :
|
|||||||
../../src/posix_api.cpp
|
../../src/posix_api.cpp
|
||||||
../../src/regex.cpp
|
../../src/regex.cpp
|
||||||
../../src/regex_debug.cpp
|
../../src/regex_debug.cpp
|
||||||
../../src/regex_raw_buffer.cpp
|
|
||||||
../../src/static_mutex.cpp
|
../../src/static_mutex.cpp
|
||||||
../../src/wide_posix_api.cpp
|
../../src/wide_posix_api.cpp
|
||||||
../../build//icu_options
|
../../build//icu_options
|
||||||
|
@ -13,6 +13,5 @@
|
|||||||
#include <libs/regex/src/posix_api.cpp>
|
#include <libs/regex/src/posix_api.cpp>
|
||||||
#include <libs/regex/src/regex.cpp>
|
#include <libs/regex/src/regex.cpp>
|
||||||
#include <libs/regex/src/regex_debug.cpp>
|
#include <libs/regex/src/regex_debug.cpp>
|
||||||
#include <libs/regex/src/regex_raw_buffer.cpp>
|
|
||||||
#include <libs/regex/src/static_mutex.cpp>
|
#include <libs/regex/src/static_mutex.cpp>
|
||||||
#include <libs/regex/src/wide_posix_api.cpp>
|
#include <libs/regex/src/wide_posix_api.cpp>
|
||||||
|
Reference in New Issue
Block a user