1
0
mirror of https://github.com/apache/httpd.git synced 2025-07-30 20:03:10 +03:00

regex: Add ap_regexec_ex() which can take a starting offset to match from.

* include/ap_mmn.h:
  Bump MMN minor.

* include/ap_regex.h:
  Declare ap_regexec_ex().

* server/util_pcre.c(ap_regexec, ap_regexec_len, ap_regexec_ex):
  Reuse existing ap_regexec_len() code to implement ap_regexec_ex() where the
  offset is given instead of zero, then implement ap_regexec{,len}() in terms
  of ap_regexec_ex().



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915267 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yann Ylavic
2024-01-16 16:51:03 +00:00
parent c9028584a8
commit e52a206008
3 changed files with 48 additions and 13 deletions

View File

@ -172,7 +172,8 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
* @return 0 for successful match, \p AP_REG_NOMATCH otherwise
*/
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
apr_size_t nmatch, ap_regmatch_t *pmatch,
int eflags);
/**
* Match a string with given length against a pre-compiled regex. The string
@ -186,10 +187,28 @@ AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
* other flags are ignored)
* @return 0 for successful match, AP_REG_NOMATCH otherwise
*/
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);
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);
/**
* Match a string with given length and at a given offset against a
* pre-compiled regex. The string does not need to be NUL-terminated.
* @param preg The pre-compiled regex
* @param buff The string to match
* @param len Length of the string to match
* @param pos Offset in the string where the match should (re)start
* @param nmatch Provide information regarding the location of any matches
* @param pmatch Provide information regarding the location of any matches
* @param eflags Bitwise OR of AP_REG_* flags (NOTBOL and NOTEOL supported,
* other flags are ignored)
* @return 0 for successful match, AP_REG_NOMATCH otherwise
*/
AP_DECLARE(int) ap_regexec_ex(const ap_regex_t *preg,
const char *buff, apr_size_t len, apr_size_t pos,
apr_size_t nmatch, ap_regmatch_t *pmatch,
int eflags);
/**
* Return the error code returned by regcomp or regexec into error messages
* @param errcode the error code returned by regexec or regcomp