summaryrefslogtreecommitdiff
path: root/pcrecpp.cc
diff options
context:
space:
mode:
authornigel <nigel@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-02-24 21:41:21 +0000
committernigel <nigel@2f5784b3-3f2a-0410-8824-cb99058d5e15>2007-02-24 21:41:21 +0000
commitced1f145fdf26ec7df4b9048a9da0ef17e9618f2 (patch)
tree371f88a16cfb5ac0a176622bcd424aa6c28c4cc8 /pcrecpp.cc
parent2550303b1f255c525d802f94d9c4411a0ccc630f (diff)
downloadpcre-ced1f145fdf26ec7df4b9048a9da0ef17e9618f2.tar.gz
Load pcre-6.5 into code/trunk.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@87 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcrecpp.cc')
-rw-r--r--pcrecpp.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/pcrecpp.cc b/pcrecpp.cc
index 0ffd221..70d59a2 100644
--- a/pcrecpp.cc
+++ b/pcrecpp.cc
@@ -397,12 +397,16 @@ int RE::TryMatch(const StringPiece& text,
pcre_extra extra = { 0 };
if (options_.match_limit() > 0) {
- extra.flags = PCRE_EXTRA_MATCH_LIMIT;
+ extra.flags |= PCRE_EXTRA_MATCH_LIMIT;
extra.match_limit = options_.match_limit();
}
+ if (options_.match_limit_recursion() > 0) {
+ extra.flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+ extra.match_limit_recursion = options_.match_limit_recursion();
+ }
int rc = pcre_exec(re, // The regular expression object
&extra,
- text.data(),
+ (text.data() == NULL) ? "" : text.data(),
text.size(),
startpos,
(anchor == UNANCHORED) ? 0 : PCRE_ANCHORED,
@@ -449,11 +453,16 @@ bool RE::DoMatchImpl(const StringPiece& text,
*consumed = vec[1];
- if (args == NULL) {
+ if (n == 0 || args == NULL) {
// We are not interested in results
return true;
}
+ if (NumberOfCapturingGroups() < n) {
+ // RE has fewer capturing groups than number of arg pointers passed in
+ return false;
+ }
+
// If we got here, we must have matched the whole pattern.
// We do not need (can not do) any more checks on the value of 'matches' here
// -- see the comment for TryMatch.
@@ -517,7 +526,7 @@ bool RE::Rewrite(string *out, const StringPiece &rewrite,
// Return the number of capturing subpatterns, or -1 if the
// regexp wasn't valid on construction.
-int RE::NumberOfCapturingGroups() {
+int RE::NumberOfCapturingGroups() const {
if (re_partial_ == NULL) return -1;
int result;
@@ -613,6 +622,7 @@ bool Arg::parse_ulong_radix(const char* str,
if (n == 0) return false;
char buf[kMaxNumberLength+1];
str = TerminateNumber(buf, str, n);
+ if (str[0] == '-') return false; // strtoul() on a negative number?!
char* end;
errno = 0;
unsigned long r = strtoul(str, &end, radix);
@@ -702,6 +712,7 @@ bool Arg::parse_ulonglong_radix(const char* str,
if (n == 0) return false;
char buf[kMaxNumberLength+1];
str = TerminateNumber(buf, str, n);
+ if (str[0] == '-') return false; // strtoull() on a negative number?!
char* end;
errno = 0;
#if defined HAVE_STRTOQ