From de0ab9092aca8eec22fff714fd0656869197c0c7 Mon Sep 17 00:00:00 2001
From: John Maddock
Date: Tue, 21 Dec 2004 17:07:46 +0000
Subject: [PATCH] Fix for .{n,} failing in partial matches. Fix for [\x0-\xff]
failing in wide character expressions.
[SVN r26566]
---
doc/Attic/history.html | 4 ++++
doc/history.html | 4 ++++
include/boost/regex/v4/perl_matcher.hpp | 8 ++++----
include/boost/regex/v4/perl_matcher_non_recursive.hpp | 3 +++
include/boost/regex/v4/perl_matcher_recursive.hpp | 3 +++
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/doc/Attic/history.html b/doc/Attic/history.html
index 6a7758ec..03a8abce 100644
--- a/doc/Attic/history.html
+++ b/doc/Attic/history.html
@@ -24,6 +24,10 @@
+ Boost 1.32.1.
+
+ -
+ Fixed bug in partial matches of bounded repeats of '.'.
Boost 1.31.0.
-
diff --git a/doc/history.html b/doc/history.html
index 6a7758ec..03a8abce 100644
--- a/doc/history.html
+++ b/doc/history.html
@@ -24,6 +24,10 @@
+ Boost 1.32.1.
+
+ -
+ Fixed bug in partial matches of bounded repeats of '.'.
Boost 1.31.0.
-
diff --git a/include/boost/regex/v4/perl_matcher.hpp b/include/boost/regex/v4/perl_matcher.hpp
index 44751e58..e3308d56 100644
--- a/include/boost/regex/v4/perl_matcher.hpp
+++ b/include/boost/regex/v4/perl_matcher.hpp
@@ -128,7 +128,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
{
if(STR_COMP(s1, p) <= 0)
{
- while(*p)++p;
+ do{ ++p; }while(*p);
++p;
if(STR_COMP(s1, p) >= 0)
return set_->isnot ? next : ++next;
@@ -136,11 +136,11 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
else
{
// skip first string
- while(*p)++p;
+ do{ ++p; }while(*p);
++p;
}
// skip second string
- while(*p)++p;
+ do{ ++p; }while(*p);
++p;
}
}
@@ -154,7 +154,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
if(STR_COMP(s1, p) == 0)
return set_->isnot ? next : ++next;
// skip string
- while(*p)++p;
+ do{ ++p; }while(*p);
++p;
}
}
diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp
index 893caa66..79e0e9bb 100644
--- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp
+++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp
@@ -554,7 +554,10 @@ bool perl_matcher::match_dot_repeat
const re_repeat* rep = static_cast(pstate);
unsigned count = (std::min)(static_cast(re_detail::distance(position, last)), static_cast(rep->greedy ? rep->max : rep->min));
if(rep->min > count)
+ {
+ position = last;
return false; // not enough text left to match
+ }
std::advance(position, count);
if(rep->greedy)
diff --git a/include/boost/regex/v4/perl_matcher_recursive.hpp b/include/boost/regex/v4/perl_matcher_recursive.hpp
index 721e44d3..10571f21 100644
--- a/include/boost/regex/v4/perl_matcher_recursive.hpp
+++ b/include/boost/regex/v4/perl_matcher_recursive.hpp
@@ -402,7 +402,10 @@ bool perl_matcher::match_dot_repeat
const re_repeat* rep = static_cast(pstate);
unsigned count = (std::min)(static_cast(re_detail::distance(position, last)), (rep->greedy ? rep->max : rep->min));
if(rep->min > count)
+ {
+ position = last;
return false; // not enough text left to match
+ }
std::advance(position, count);
if((rep->leading) && (count < rep->max) && (rep->greedy))
restart = position;