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

* include/ap_regex.h: Include apr.h not stdlib.h; replace pointless

regoff_t typedef with int; s/size_t/apr_size_t/;.  Comment fixes.

* server/util_pcre.c: s/size_t/apr_size_t/.

* include/httpd.h: Include stdlib.h here instead since many other
files assume it was included by httpd.h at some point.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@153407 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joe Orton
2005-02-11 14:57:34 +00:00
parent 502606508c
commit 27759dec9a
3 changed files with 26 additions and 26 deletions

View File

@ -14,9 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
/* This is the header for the POSIX wrapper interface to the PCRE Perl- /* Derived from PCRE's pcreposix.h.
Compatible Regular Expression library. It defines the things POSIX says should
be there. I hope.
Copyright (c) 1997-2004 University of Cambridge Copyright (c) 1997-2004 University of Cambridge
@ -52,9 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef AP_REGEX_H #ifndef AP_REGEX_H
#define AP_REGEX_H #define AP_REGEX_H
/* Have to include stdlib.h in order to ensure that size_t is defined. */ #include "apr.h"
#include <stdlib.h>
/* Allow for C++ users */ /* Allow for C++ users */
@ -82,17 +78,15 @@ enum {
/* The structure representing a compiled regular expression. */ /* The structure representing a compiled regular expression. */
typedef struct { typedef struct {
void *re_pcre; void *re_pcre;
size_t re_nsub; apr_size_t re_nsub;
size_t re_erroffset; apr_size_t re_erroffset;
} ap_regex_t; } ap_regex_t;
typedef int regoff_t;
/* The structure in which a captured offset is returned. */ /* The structure in which a captured offset is returned. */
typedef struct { typedef struct {
regoff_t rm_so; int rm_so;
regoff_t rm_eo; int rm_eo;
} ap_regmatch_t; } ap_regmatch_t;
#ifndef AP_DECLARE #ifndef AP_DECLARE
@ -102,7 +96,7 @@ typedef struct {
/* The functions */ /* The functions */
/** /**
* Compile a regeular expression. * Compile a regular expression.
* @param preg Returned compiled regex * @param preg Returned compiled regex
* @param regex The regular expression string * @param regex The regular expression string
* @param cflags Must be zero (currently). * @param cflags Must be zero (currently).
@ -111,7 +105,7 @@ typedef struct {
AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags); AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
/** /**
* Match a null-terminated string against a pre-compiled regex. * Match a NUL-terminated string against a pre-compiled regex.
* @param preg The pre-compiled regex * @param preg The pre-compiled regex
* @param string The string to match * @param string The string to match
* @param nmatch Provide information regarding the location of any matches * @param nmatch Provide information regarding the location of any matches
@ -120,7 +114,7 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
* @return 0 for successful match, #REG_NOMATCH otherwise * @return 0 for successful match, #REG_NOMATCH otherwise
*/ */
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string, AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
size_t nmatch, ap_regmatch_t *pmatch, int eflags); apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
/** /**
* Return the error code returned by regcomp or regexec into error messages * Return the error code returned by regcomp or regexec into error messages
@ -129,8 +123,8 @@ AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
* @param errbuf A buffer to store the error in * @param errbuf A buffer to store the error in
* @param errbuf_size The size of the buffer * @param errbuf_size The size of the buffer
*/ */
AP_DECLARE(size_t) ap_regerror(int errcode, const ap_regex_t *preg, AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
char *errbuf, size_t errbuf_size); char *errbuf, apr_size_t errbuf_size);
/** Destroy a pre-compiled regex. /** Destroy a pre-compiled regex.
* @param preg The pre-compiled regex to free. * @param preg The pre-compiled regex to free.

View File

@ -32,6 +32,7 @@
#include "ap_release.h" #include "ap_release.h"
#include "apr.h"
#include "apr_general.h" #include "apr_general.h"
#include "apr_tables.h" #include "apr_tables.h"
#include "apr_pools.h" #include "apr_pools.h"
@ -44,6 +45,10 @@
#include "ap_regex.h" #include "ap_regex.h"
#if APR_HAVE_STDLIB_H
#include <stdlib.h>
#endif
/* Note: util_uri.h is also included, see below */ /* Note: util_uri.h is also included, see below */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -67,11 +67,11 @@ static const char *const pstring[] = {
"match failed" /* AP_REG_NOMATCH */ "match failed" /* AP_REG_NOMATCH */
}; };
AP_DECLARE(size_t) ap_regerror(int errcode, const ap_regex_t *preg, AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
char *errbuf, size_t errbuf_size) char *errbuf, apr_size_t errbuf_size)
{ {
const char *message, *addmessage; const char *message, *addmessage;
size_t length, addlength; apr_size_t length, addlength;
message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))? message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
"unknown error code" : pstring[errcode]; "unknown error code" : pstring[errcode];
@ -157,8 +157,9 @@ 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 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. */ in a macro that can be changed at configure time. */
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string, size_t nmatch, AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
ap_regmatch_t pmatch[], int eflags) apr_size_t nmatch, ap_regmatch_t pmatch[],
int eflags)
{ {
int rc; int rc;
int options = 0; int options = 0;
@ -169,7 +170,7 @@ int allocated_ovector = 0;
if ((eflags & AP_REG_NOTBOL) != 0) options |= PCRE_NOTBOL; if ((eflags & AP_REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
if ((eflags & AP_REG_NOTEOL) != 0) options |= PCRE_NOTEOL; if ((eflags & AP_REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
((ap_regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */ ((ap_regex_t *)preg)->re_erroffset = (apr_size_t)(-1); /* Only has meaning after compile */
if (nmatch > 0) if (nmatch > 0)
{ {
@ -192,8 +193,8 @@ if (rc == 0) rc = nmatch; /* All captured slots were filled in */
if (rc >= 0) if (rc >= 0)
{ {
size_t i; apr_size_t i;
for (i = 0; i < (size_t)rc; i++) for (i = 0; i < (apr_size_t)rc; i++)
{ {
pmatch[i].rm_so = ovector[i*2]; pmatch[i].rm_so = ovector[i*2];
pmatch[i].rm_eo = ovector[i*2+1]; pmatch[i].rm_eo = ovector[i*2+1];