From 63366c900bff1d469323edc6ebaaf818b8f346d1 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sat, 21 May 2011 20:34:05 +0000 Subject: Add ap_regexec_len() function that works with non-null-terminated strings. PR: 51231 Submitted by: Yehezkel Horowitz , Stefan Fritsch git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1125802 13f79535-47bb-0310-9956-ffa450edef68 --- server/util_pcre.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'server/util_pcre.c') diff --git a/server/util_pcre.c b/server/util_pcre.c index f40d45cbb2..0589e1ada0 100644 --- a/server/util_pcre.c +++ b/server/util_pcre.c @@ -152,11 +152,17 @@ the POSIX structures as was done in earlier releases when PCRE needed only 2 ints. However, if the number of possible capturing brackets is small, use a block of store on the stack, to reduce the use of malloc/free. The threshold is in a macro that can be changed at configure time. */ - AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string, - apr_size_t nmatch, ap_regmatch_t pmatch[], + apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags) { +return ap_regexec_len(preg, string, strlen(string), nmatch, pmatch, eflags); +} + +AP_DECLARE(int) ap_regexec_len(const ap_regex_t *preg, const char *buff, + apr_size_t len, apr_size_t nmatch, + ap_regmatch_t *pmatch, int eflags) +{ int rc; int options = 0; int *ovector = NULL; @@ -182,7 +188,7 @@ if (nmatch > 0) } } -rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (int)strlen(string), +rc = pcre_exec((const pcre *)preg->re_pcre, NULL, buff, (int)len, 0, options, ovector, nmatch * 3); if (rc == 0) rc = nmatch; /* All captured slots were filled in */ -- cgit v1.2.3