397 |
|
|
398 |
pcre_extra extra = { 0 }; |
pcre_extra extra = { 0 }; |
399 |
if (options_.match_limit() > 0) { |
if (options_.match_limit() > 0) { |
400 |
extra.flags = PCRE_EXTRA_MATCH_LIMIT; |
extra.flags |= PCRE_EXTRA_MATCH_LIMIT; |
401 |
extra.match_limit = options_.match_limit(); |
extra.match_limit = options_.match_limit(); |
402 |
} |
} |
403 |
|
if (options_.match_limit_recursion() > 0) { |
404 |
|
extra.flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; |
405 |
|
extra.match_limit_recursion = options_.match_limit_recursion(); |
406 |
|
} |
407 |
int rc = pcre_exec(re, // The regular expression object |
int rc = pcre_exec(re, // The regular expression object |
408 |
&extra, |
&extra, |
409 |
text.data(), |
(text.data() == NULL) ? "" : text.data(), |
410 |
text.size(), |
text.size(), |
411 |
startpos, |
startpos, |
412 |
(anchor == UNANCHORED) ? 0 : PCRE_ANCHORED, |
(anchor == UNANCHORED) ? 0 : PCRE_ANCHORED, |
453 |
|
|
454 |
*consumed = vec[1]; |
*consumed = vec[1]; |
455 |
|
|
456 |
if (args == NULL) { |
if (n == 0 || args == NULL) { |
457 |
// We are not interested in results |
// We are not interested in results |
458 |
return true; |
return true; |
459 |
} |
} |
460 |
|
|
461 |
|
if (NumberOfCapturingGroups() < n) { |
462 |
|
// RE has fewer capturing groups than number of arg pointers passed in |
463 |
|
return false; |
464 |
|
} |
465 |
|
|
466 |
// If we got here, we must have matched the whole pattern. |
// If we got here, we must have matched the whole pattern. |
467 |
// We do not need (can not do) any more checks on the value of 'matches' here |
// We do not need (can not do) any more checks on the value of 'matches' here |
468 |
// -- see the comment for TryMatch. |
// -- see the comment for TryMatch. |
526 |
|
|
527 |
// Return the number of capturing subpatterns, or -1 if the |
// Return the number of capturing subpatterns, or -1 if the |
528 |
// regexp wasn't valid on construction. |
// regexp wasn't valid on construction. |
529 |
int RE::NumberOfCapturingGroups() { |
int RE::NumberOfCapturingGroups() const { |
530 |
if (re_partial_ == NULL) return -1; |
if (re_partial_ == NULL) return -1; |
531 |
|
|
532 |
int result; |
int result; |
622 |
if (n == 0) return false; |
if (n == 0) return false; |
623 |
char buf[kMaxNumberLength+1]; |
char buf[kMaxNumberLength+1]; |
624 |
str = TerminateNumber(buf, str, n); |
str = TerminateNumber(buf, str, n); |
625 |
|
if (str[0] == '-') return false; // strtoul() on a negative number?! |
626 |
char* end; |
char* end; |
627 |
errno = 0; |
errno = 0; |
628 |
unsigned long r = strtoul(str, &end, radix); |
unsigned long r = strtoul(str, &end, radix); |
712 |
if (n == 0) return false; |
if (n == 0) return false; |
713 |
char buf[kMaxNumberLength+1]; |
char buf[kMaxNumberLength+1]; |
714 |
str = TerminateNumber(buf, str, n); |
str = TerminateNumber(buf, str, n); |
715 |
|
if (str[0] == '-') return false; // strtoull() on a negative number?! |
716 |
char* end; |
char* end; |
717 |
errno = 0; |
errno = 0; |
718 |
#if defined HAVE_STRTOQ |
#if defined HAVE_STRTOQ |