Compare commits

..

21 Commits

Author SHA1 Message Date
86f82635d4 Merge branch 'develop' 2021-07-03 10:17:35 +01:00
dfd700d858 Merge pull request #142 from boostorg/issue140
Fix infinite loop in parser.
2021-06-26 18:26:07 +01:00
d312a085b1 Fix infinite loop in parser.
Fixes: https://github.com/boostorg/regex/issues/140.
2021-06-26 13:52:23 +01:00
0c8158f6ce Merge branch 'develop' 2021-06-25 19:19:28 +01:00
194ab4d646 Merge pull request #139 from volo-zyko/fix-clangcl-icu-linking
Fix linking with ICU libs when building with clang-cl
2021-06-12 14:22:21 +01:00
1728f98485 Merge pull request #138 from volo-zyko/add-icu-search-paths
Add ICU libs search paths even when ICU_ICUUC_NAME, ICU_ICUDT_NAME, and ICU_ICUIN_NAME are provided by user
2021-06-12 14:22:02 +01:00
5e42d51d49 Merge pull request #137 from volo-zyko/icu-data-dir
Fix ICU libs detection when ICU resources are in a separate directory
2021-06-12 14:21:39 +01:00
151c144b75 Merge pull request #135 from Kojoley/prune-iostream-includes
Prune <iostream> includes
2021-06-11 18:21:35 +01:00
f4c21ba011 Merge pull request #134 from Kojoley/cease-dependence-on-iterator
Cease dependence on Iterator
2021-06-11 18:20:52 +01:00
e9cde852b3 Merge pull request #132 from ClaymorePT/regex_mutex_fix
Fixes wrong type for mutex in regex v5
2021-06-11 18:12:45 +01:00
d619d934f3 Fix linking with ICU libs when building with clang-cl 2021-06-09 21:45:10 +03:00
da20a5d1dc Add ICU libs search paths even when ICU_ICUUC_NAME, ICU_ICUDT_NAME,
and ICU_ICUIN_NAME are provided by user
2021-06-09 21:37:41 +03:00
d604d1702e Fix ICU libs detection when ICU resources are in
a separate directory
2021-06-09 21:32:40 +03:00
cd30a0560f Prune <iostream> includes 2021-06-07 02:11:41 +03:00
d2a5ddd8a9 Cease dependence on Iterator
It is a fat dependence because it brings Fusion.
2021-06-07 01:47:25 +03:00
dc9c5c50be Don't redefine macros.
Fixes https://github.com/boostorg/regex/issues/127
2021-06-06 09:07:28 +01:00
6064875bff Fixes wrong type for mutex in regex v5
With the Boost.Regex to ehader-only library, the declaration
of a mutex that should have been changed from boost::static_mutex
to std::mutex was left behind. This was preventing regex from
being built for older arm platforms [1]

[1]: https://github.com/openwrt/packages/issues/15725

Signed-off-by: Carlos Miguel Ferreira <carlosmf.pt@gmail.com>
2021-06-03 23:10:37 +01:00
a3f97b5bec Merge pull request #126 from boostorg/header_fix
Add missing #include  for release.
2021-04-12 08:21:42 +01:00
13a13e58c9 Merge branch 'develop' into header_fix 2021-04-11 18:14:48 +01:00
7da62c1edb Merge pull request #125 from mborland/develop
Add missing header
2021-04-11 18:11:52 +01:00
51d2661b76 Add missing header 2021-04-10 18:08:00 +03:00
11 changed files with 162 additions and 47 deletions

View File

@ -57,7 +57,7 @@ if ! $(disable-icu)
if $(ICU_ICUUC_NAME)
{
lib icuuc : : <name>$(ICU_ICUUC_NAME) ;
lib icuuc : : <name>$(ICU_ICUUC_NAME) <conditional>@path_options ;
}
else
{
@ -71,7 +71,7 @@ if ! $(disable-icu)
}
if $(ICU_ICUDT_NAME)
{
lib icudt : : <name>$(ICU_ICUDT_NAME) ;
lib icudt : : <name>$(ICU_ICUDT_NAME) <conditional>@path_options ;
}
else
{
@ -85,7 +85,7 @@ if ! $(disable-icu)
}
if $(ICU_ICUIN_NAME)
{
lib icuin : : <name>$(ICU_ICUIN_NAME) ;
lib icuin : : <name>$(ICU_ICUIN_NAME) <conditional>@path_options ;
}
else
{
@ -110,10 +110,33 @@ if ! $(disable-icu)
<runtime-link>static:<library>icuuc
<runtime-link>static:<library>icudt
<runtime-link>static:<library>icuin
<target-os>windows,<toolset>clang:<linkflags>"advapi32.lib"
<define>BOOST_HAS_ICU=1
<runtime-link>static:<define>U_STATIC_IMPLEMENTATION=1
;
if [ modules.peek : ICU_DATA_DIR ]
{
rule data-dir-options ( properties * )
{
local result ;
local data_dir = [ modules.peek : ICU_DATA_DIR ] ;
if <toolset>emscripten in $(properties)
{
result = <define>ICU_DATA_DIR=\\\"/$(data_dir:BS)\\\"
"<linkflags>--embed-file $(data_dir)@/$(data_dir:BS)"
;
}
else
{
result = <define>ICU_DATA_DIR=\\\"$(data_dir)\\\" ;
}
return $(result) ;
}
ICU_OPTS += <conditional>@data-dir-options ;
}
}
exe has_icu : has_icu_test.cpp : $(ICU_OPTS) ;

View File

@ -28,6 +28,10 @@ void print_error(UErrorCode err, const char* func)
int main()
{
#ifdef ICU_DATA_DIR
::u_setDataDirectory(ICU_DATA_DIR);
#endif
// To detect possible binary mismatches between the installed ICU build, and whatever
// C++ std lib's we're using, we need to:
// * Make sure we call ICU C++ API's

View File

@ -29,7 +29,7 @@
#endif
#include <bitset>
#include <vector>
#include <iostream>
#include <ostream>
#ifdef BOOST_REGEX_CXX03
#define RW_NS boost

View File

@ -1124,6 +1124,9 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
}
else
contin = false;
break;
default:
contin = false;
}
}
else

View File

@ -62,7 +62,6 @@ Accepts UTF-32 code points and forwards them on as UTF-16 code points.
#define BOOST_REGEX_V4_UNICODE_ITERATOR_HPP
#include <boost/cstdint.hpp>
#include <boost/regex/config.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <stdexcept>
@ -145,10 +144,7 @@ inline void invalid_utf32_code_point(::boost::uint32_t val)
template <class BaseIterator, class U16Type = ::boost::uint16_t>
class u32_to_u16_iterator
: public boost::iterator_facade<u32_to_u16_iterator<BaseIterator, U16Type>, U16Type, std::bidirectional_iterator_tag, const U16Type>
{
typedef boost::iterator_facade<u32_to_u16_iterator<BaseIterator, U16Type>, U16Type, std::bidirectional_iterator_tag, const U16Type> base_type;
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
@ -157,14 +153,19 @@ class u32_to_u16_iterator
#endif
public:
typename base_type::reference
dereference()const
typedef std::ptrdiff_t difference_type;
typedef U16Type value_type;
typedef value_type const* pointer;
typedef value_type const reference;
typedef std::bidirectional_iterator_tag iterator_category;
reference operator*()const
{
if(m_current == 2)
extract_current();
return m_values[m_current];
}
bool equal(const u32_to_u16_iterator& that)const
bool operator==(const u32_to_u16_iterator& that)const
{
if(m_position == that.m_position)
{
@ -174,7 +175,11 @@ public:
}
return false;
}
void increment()
bool operator!=(const u32_to_u16_iterator& that)const
{
return !(*this == that);
}
u32_to_u16_iterator& operator++()
{
// if we have a pending read then read now, so that we know whether
// to skip a position, or move to a low-surrogate:
@ -191,8 +196,15 @@ public:
m_current = 2;
++m_position;
}
return *this;
}
void decrement()
u32_to_u16_iterator operator++(int)
{
u32_to_u16_iterator r(*this);
++(*this);
return r;
}
u32_to_u16_iterator& operator--()
{
if(m_current != 1)
{
@ -205,6 +217,13 @@ public:
{
m_current = 0;
}
return *this;
}
u32_to_u16_iterator operator--(int)
{
u32_to_u16_iterator r(*this);
--(*this);
return r;
}
BaseIterator base()const
{
@ -258,9 +277,7 @@ private:
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u16_to_u32_iterator
: public boost::iterator_facade<u16_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type>
{
typedef boost::iterator_facade<u16_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type;
// special values for pending iterator reads:
BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu);
@ -272,31 +289,54 @@ class u16_to_u32_iterator
#endif
public:
typename base_type::reference
dereference()const
typedef std::ptrdiff_t difference_type;
typedef U32Type value_type;
typedef value_type const* pointer;
typedef value_type const reference;
typedef std::bidirectional_iterator_tag iterator_category;
reference operator*()const
{
if(m_value == pending_read)
extract_current();
return m_value;
}
bool equal(const u16_to_u32_iterator& that)const
bool operator==(const u16_to_u32_iterator& that)const
{
return m_position == that.m_position;
}
void increment()
bool operator!=(const u16_to_u32_iterator& that)const
{
return !(*this == that);
}
u16_to_u32_iterator& operator++()
{
// skip high surrogate first if there is one:
if(detail::is_high_surrogate(*m_position)) ++m_position;
++m_position;
m_value = pending_read;
return *this;
}
void decrement()
u16_to_u32_iterator operator++(int)
{
u16_to_u32_iterator r(*this);
++(*this);
return r;
}
u16_to_u32_iterator& operator--()
{
--m_position;
// if we have a low surrogate then go back one more:
if(detail::is_low_surrogate(*m_position))
--m_position;
m_value = pending_read;
return *this;
}
u16_to_u32_iterator operator--(int)
{
u16_to_u32_iterator r(*this);
--(*this);
return r;
}
BaseIterator base()const
{
@ -375,10 +415,7 @@ private:
template <class BaseIterator, class U8Type = ::boost::uint8_t>
class u32_to_u8_iterator
: public boost::iterator_facade<u32_to_u8_iterator<BaseIterator, U8Type>, U8Type, std::bidirectional_iterator_tag, const U8Type>
{
typedef boost::iterator_facade<u32_to_u8_iterator<BaseIterator, U8Type>, U8Type, std::bidirectional_iterator_tag, const U8Type> base_type;
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
typedef typename std::iterator_traits<BaseIterator>::value_type base_value_type;
@ -387,14 +424,19 @@ class u32_to_u8_iterator
#endif
public:
typename base_type::reference
dereference()const
typedef std::ptrdiff_t difference_type;
typedef U8Type value_type;
typedef value_type const* pointer;
typedef value_type const reference;
typedef std::bidirectional_iterator_tag iterator_category;
reference operator*()const
{
if(m_current == 4)
extract_current();
return m_values[m_current];
}
bool equal(const u32_to_u8_iterator& that)const
bool operator==(const u32_to_u8_iterator& that)const
{
if(m_position == that.m_position)
{
@ -405,7 +447,11 @@ public:
}
return false;
}
void increment()
bool operator!=(const u32_to_u8_iterator& that)const
{
return !(*this == that);
}
u32_to_u8_iterator& operator++()
{
// if we have a pending read then read now, so that we know whether
// to skip a position, or move to a low-surrogate:
@ -422,8 +468,15 @@ public:
m_current = 4;
++m_position;
}
return *this;
}
void decrement()
u32_to_u8_iterator operator++(int)
{
u32_to_u8_iterator r(*this);
++(*this);
return r;
}
u32_to_u8_iterator& operator--()
{
if((m_current & 3) == 0)
{
@ -435,6 +488,13 @@ public:
}
else
--m_current;
return *this;
}
u32_to_u8_iterator operator--(int)
{
u32_to_u8_iterator r(*this);
--(*this);
return r;
}
BaseIterator base()const
{
@ -501,9 +561,7 @@ private:
template <class BaseIterator, class U32Type = ::boost::uint32_t>
class u8_to_u32_iterator
: public boost::iterator_facade<u8_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type>
{
typedef boost::iterator_facade<u8_to_u32_iterator<BaseIterator, U32Type>, U32Type, std::bidirectional_iterator_tag, const U32Type> base_type;
// special values for pending iterator reads:
BOOST_STATIC_CONSTANT(U32Type, pending_read = 0xffffffffu);
@ -515,18 +573,27 @@ class u8_to_u32_iterator
#endif
public:
typename base_type::reference
dereference()const
typedef std::ptrdiff_t difference_type;
typedef U32Type value_type;
typedef value_type const* pointer;
typedef value_type const reference;
typedef std::bidirectional_iterator_tag iterator_category;
reference operator*()const
{
if(m_value == pending_read)
extract_current();
return m_value;
}
bool equal(const u8_to_u32_iterator& that)const
bool operator==(const u8_to_u32_iterator& that)const
{
return m_position == that.m_position;
}
void increment()
bool operator!=(const u8_to_u32_iterator& that)const
{
return !(*this == that);
}
u8_to_u32_iterator& operator++()
{
// We must not start with a continuation character:
if((static_cast<boost::uint8_t>(*m_position) & 0xC0) == 0x80)
@ -549,8 +616,15 @@ public:
std::advance(m_position, c);
}
m_value = pending_read;
return *this;
}
void decrement()
u8_to_u32_iterator operator++(int)
{
u8_to_u32_iterator r(*this);
++(*this);
return r;
}
u8_to_u32_iterator& operator--()
{
// Keep backtracking until we don't have a trailing character:
unsigned count = 0;
@ -559,6 +633,13 @@ public:
if(count != detail::utf8_trailing_byte_count(*m_position))
invalid_sequence();
m_value = pending_read;
return *this;
}
u8_to_u32_iterator operator--(int)
{
u8_to_u32_iterator r(*this);
--(*this);
return r;
}
BaseIterator base()const
{

View File

@ -1098,6 +1098,9 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
}
else
contin = false;
break;
default:
contin = false;
}
}
else

View File

@ -85,10 +85,10 @@ struct mem_block_node
struct mem_block_cache
{
// this member has to be statically initialsed:
mem_block_node* next;
unsigned cached_blocks;
mem_block_node* next { nullptr };
unsigned cached_blocks { 0 };
#ifdef BOOST_HAS_THREADS
boost::static_mutex mut;
std::mutex mut;
#endif
~mem_block_cache()
@ -133,11 +133,7 @@ struct mem_block_cache
}
static mem_block_cache& instance()
{
#ifdef BOOST_HAS_THREADS
static mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, };
#else
static mem_block_cache block_cache = { 0, 0, };
#endif
static mem_block_cache block_cache;
return block_cache;
}
};

View File

@ -29,6 +29,7 @@
#include <cctype>
#include <locale>
#include <cwctype>
#include <limits>
namespace boost{ namespace BOOST_REGEX_DETAIL_NS{

View File

@ -67,8 +67,6 @@ Accepts UTF-32 code points and forwards them on as UTF-16 code points.
#include <ios>
#include <limits.h> // CHAR_BIT
#include <iostream>
#ifndef BOOST_REGEX_STANDALONE
#include <boost/throw_exception.hpp>
#endif

View File

@ -29,8 +29,12 @@
#include <boost/regex/v5/primary_transform.hpp>
#include <boost/regex/v5/object_cache.hpp>
#define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN
#ifndef VC_EXTRALEAN
# define VC_EXTRALEAN
#endif
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(UNDER_CE)

View File

@ -58,6 +58,8 @@ void test_independent_subs()
TEST_REGEX_SEARCH("word (?>[a-zA-Z0-9]+ ){0,30}otherword", perl, "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I really really hope otherword", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("((?>Z)+|A)+", perl, "ZABCDEFG", match_default, make_array(0, 2, 1, 2, -2, -2));
TEST_INVALID_REGEX("((?>)+|A)+", perl);
// Bug https://github.com/boostorg/regex/issues/140:
TEST_REGEX_SEARCH("1?+(?#)1", perl, "22113", match_default, make_array(2, 4, -2, -2));
}
void test_conditionals()