Hi Guenter, Just a tweak or two and its ready. The preg calloc only applies to the HAS_PCRE case and PREGCOMP isn't needed. Otherwise it looks good. I'll test and commit it tomorrow.
-Kurt From: "Guenter Knauf" <[EMAIL PROTECTED]> > Hi Kurt, > > I've reviewed your patch and have some comments included inline below. > > > regcomp and ap_pregcomp are not interchangeable like this. ap_pregcomp > > needs an apr_pool to be passed to it and it returns the regex_t. I > > think (apr_pool_t *)uriEnv->pool->_private is correct here (Henri?, > > Jean-Frederic?). > ok, I believe I got that now. For easier review I copy here the relevant parts of the headers, followed by the new patch. Please review again - if it is ok so, I put the patchfile on my host, and add the other suggestions to the makefiles. > > thanks, Guenter. > > /** > * Compile a regular expression to be used later > * @param p The pool to allocate from > * @param pattern the regular expression to compile > * @param cflags The bitwise or of one or more of the following: > * @li #REG_EXTENDED - Use POSIX extended Regular Expressions > * @li #REG_ICASE - Ignore case > * @li #REG_NOSUB - Support for substring addressing of matches > * not required > * @li #REG_NEWLINE - Match-any-character operators don't match new-line > * @return The compiled regular expression > */ > AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern, > int cflags); > > /** > * Match a null-terminated string against a pre-compiled regex. > * @param preg The pre-compiled regex > * @param string The string to match > * @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 any of: > * @li #REG_NOTBOL - match-beginning-of-line operator always > * fails to match > * @li #REG_NOTEOL - match-end-of-line operator always fails to match > * @return 0 for successful match, #REG_NOMATCH otherwise > */ > AP_DECLARE(int) ap_regexec(regex_t *preg, const char *string, > size_t nmatch, regmatch_t pmatch[], int eflags); > > > extern int regcomp(regex_t *, const char *, int); > extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int); > > > ###################################################################### ######### > --- jk_uriEnv.c.orig Tue Feb 24 12:30:10 2004 > +++ jk_uriEnv.c Thu Feb 26 20:34:46 2004 > @@ -28,9 +28,15 @@ > #include "jk_uriMap.h" > #include "jk_registry.h" > > +#ifdef HAS_AP_PCRE > +#include "httpd.h" > +#define PREGCOMP ap_pregcomp > +#else > #ifdef HAS_PCRE > #include "pcre.h" > #include "pcreposix.h" > +#define PREGCOMP regcomp > +#endif > #endif > > /* return non-zero if pattern has any glob chars in it */ > @@ -65,7 +71,7 @@ > int pcre = 0; > > if (*name == '$') { > -#ifdef HAS_PCRE > +#if defined(HAS_PCRE) || defined(HAS_AP_PCRE) > ++name; > uriEnv->uri = uriEnv->pool->pstrdup(env, uriEnv->pool, name); > uriEnv->match_type = MATCH_TYPE_REGEXP; > @@ -74,7 +80,11 @@ > name); > { > regex_t *preg = (regex_t *)uriEnv->pool->calloc( env, uriEnv->pool, sizeof(regex_t)); > +#ifdef HAS_AP_PCRE > + if ((preg = ap_pregcomp((apr_pool_t *)uriEnv->pool->_private, uriEnv->uri, REG_EXTENDED)) == NULL) { > +#else > if (regcomp(preg, uriEnv->uri, REG_EXTENDED)) { > +#endif > env->l->jkLog(env, env->l, JK_LOG_DEBUG, > "uriEnv.parseName() error compiling regexp %s\n", > uri); > @@ -132,14 +142,18 @@ > if (pcre) { > ++uri; > uriEnv->match_type = MATCH_TYPE_REGEXP; > -#ifdef HAS_PCRE > +#if defined(HAS_PCRE) || defined(HAS_AP_PCRE) > uriEnv->uri = uriEnv->pool->pstrdup(env, uriEnv->pool, uri); > env->l->jkLog(env, env->l, JK_LOG_DEBUG, > "uriEnv.parseName() parsing regexp %s\n", > uri); > { > regex_t *preg = (regex_t *)uriEnv->pool->calloc( env, uriEnv->pool, sizeof(regex_t)); > +#ifdef HAS_AP_PCRE > + if ((preg = ap_pregcomp((apr_pool_t *)uriEnv->pool->_private, uriEnv->uri, REG_EXTENDED)) == NULL) { > +#else > if (regcomp(preg, uriEnv->uri, REG_EXTENDED)) { > +#endif > env->l->jkLog(env, env->l, JK_LOG_DEBUG, > "uriEnv.parseName() error compiling regexp %s\n", > uri); > ###################################################################### ######### > --- jk_uriMap.c.orig Tue Feb 24 12:30:10 2004 > +++ jk_uriMap.c Thu Feb 26 19:03:32 2004 > @@ -34,9 +34,15 @@ > #include "jk_uriMap.h" > #include "jk_registry.h" > > +#ifdef HAS_AP_PCRE > +#include "httpd.h" > +#define REGEXEC ap_regexec > +#else > #ifdef HAS_PCRE > #include "pcre.h" > #include "pcreposix.h" > +#define REGEXEC regexec > +#endif > #endif > > static INLINE const char *jk2_findExtension(jk_env_t *env, const char *uri); > @@ -304,7 +310,7 @@ > return uriMap->vhosts->get(env, uriMap->vhosts, "*"); > } > > -#ifdef HAS_PCRE > +#if defined(HAS_PCRE) || defined(HAS_AP_PCRE) > static jk_uriEnv_t *jk2_uriMap_regexpMap(jk_env_t *env, jk_uriMap_t *uriMap, > jk_map_t *mapTable, const char *uri) > { > @@ -317,7 +323,7 @@ > if (uwr->regexp) { > regex_t *r = (regex_t *)uwr->regexp; > regmatch_t regm[10]; > - if (!regexec(r, uri, r->re_nsub + 1, regm, 0)) { > + if (!REGEXEC(r, uri, r->re_nsub + 1, regm, 0)) { > return uwr; > } > } > > > > -------------------------------------------------------------------- - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]