]> git.pld-linux.org Git - packages/apache.git/blob - apache2-pcre-patch.diff
- %desc
[packages/apache.git] / apache2-pcre-patch.diff
1 diff -x {arch} -x .arch-ids -urN orig/apache2/Makefile.in mod/apache2/Makefile.in
2 --- orig/apache2/Makefile.in    2004-03-07 03:18:24.000000000 -0500
3 +++ mod/apache2/Makefile.in     2004-03-07 01:18:10.000000000 -0500
4 @@ -178,7 +178,9 @@
5         @cp -p $(srcdir)/modules/http/mod_core.h $(DESTDIR)$(includedir)
6         @cp -p $(srcdir)/modules/proxy/mod_proxy.h $(DESTDIR)$(includedir)
7         @cp -p $(srcdir)/modules/ssl/*.h $(DESTDIR)$(includedir)
8 -       @cp -p $(srcdir)/srclib/pcre/pcre*.h $(DESTDIR)$(includedir)
9 +       @if test "$(AP_EXTERN_PCRE)" != "0"; then \
10 +               cp -p $(srcdir)/srclib/pcre/pcre*.h $(DESTDIR)$(includedir); \
11 +       fi;
12         @cp -p $(srcdir)/os/$(OS_DIR)/*.h $(DESTDIR)$(includedir)
13         @chmod 644 $(DESTDIR)$(includedir)/*.h
14  
15 diff -x {arch} -x .arch-ids -urN orig/apache2/acinclude.m4 mod/apache2/acinclude.m4
16 --- orig/apache2/acinclude.m4   2004-03-07 03:18:24.000000000 -0500
17 +++ mod/apache2/acinclude.m4    2004-03-07 01:18:09.000000000 -0500
18 @@ -494,6 +494,58 @@
19  ])
20  
21  dnl
22 +dnl APACHE_CHECK_PCRE
23 +dnl Apache includes it's own version of PCRE; however, if PCRE exists
24 +dnl on the build system, we link against that instead of building
25 +dnl Apache's own PCRE.
26 +dnl
27 +AC_DEFUN(APACHE_CHECK_PCRE, [
28 +  AC_MSG_CHECKING(for external PCRE library)
29 +  ap_pcre_base=""
30 +  ap_test_pcre=1
31 +  AP_EXTERN_PCRE=0
32 +
33 +  AC_ARG_WITH([pcre], AS_HELP_STRING([--with-external-pcre],
34 +      [use external libpcre (versus apache-supplied pcre)]), [
35 +    if test "x$withval" = "xno"; then
36 +      ap_test_pcre=0;
37 +    elif test "x$withval" != "xyes" -a "x$withval" != "x"; then
38 +      ap_pcre_base="$withval"
39 +    fi
40 +  ])
41 +
42 +  if test "$ap_test_pcre" != "0"; then
43 +    ap_pcre_conf="pcre-config"
44 +    if test -f "$ap_pcre_base"; then
45 +      ap_pcre_conf="$ap_pcre_base";
46 +    elif test -f "$ap_pcre_base/pcre-config"; then
47 +      ap_pcre_conf="$ap_pcre_base/pcre-config";
48 +    elif test -f "$ap_pcre_base/bin/pcre-config"; then
49 +      ap_pcre_conf="$ap_pcre_base/bin/pcre-config";
50 +    fi
51 +
52 +    ap_save_CFLAGS="$CFLAGS"
53 +    ap_save_LIBS="$LIBS"
54 +    CFLAGS="$CFLAGS `$ap_pcre_conf --cflags 2>/dev/null`"
55 +    LIBS="$LIBS `$ap_pcre_conf --libs 2>/dev/null`"
56 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pcre.h>]],
57 +        [[char *foo = pcre_version();]])], [
58 +      AP_EXTERN_PCRE=1
59 +    ], [
60 +      CFLAGS="$ap_save_CFLAGS"
61 +      LIBS="$ap_save_LIBS"
62 +    ])
63 +  fi
64 +
65 +  if test "$AP_EXTERN_PCRE" = "1"; then
66 +    AC_MSG_RESULT(yes)
67 +  else
68 +    AC_MSG_RESULT(no)
69 +  fi
70 +  AC_SUBST(AP_EXTERN_PCRE)
71 +])
72 +
73 +dnl
74  dnl APACHE_EXPORT_ARGUMENTS
75  dnl Export (via APACHE_SUBST) the various path-related variables that
76  dnl apache will use while generating scripts like autoconf and apxs and
77 diff -x {arch} -x .arch-ids -urN orig/apache2/configure.in mod/apache2/configure.in
78 --- orig/apache2/configure.in   2004-03-07 03:18:27.000000000 -0500
79 +++ mod/apache2/configure.in    2004-03-07 01:18:08.000000000 -0500
80 @@ -114,10 +114,14 @@
81  AC_PROG_CC
82  AC_PROG_CPP
83  
84 -echo $ac_n "${nl}Configuring PCRE regular expression library ...${nl}"
85 -
86 -APR_SUBDIR_CONFIG(srclib/pcre,
87 -                  [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
88 +APACHE_CHECK_PCRE
89 +if test "$AP_EXTERN_PCRE" = "0"; then
90 +  echo $ac_n "${nl}Configuring PCRE regular expression library ...${nl}"
91 +  APR_SUBDIR_CONFIG(srclib/pcre,
92 +      [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir])
93 +  AP_BUILD_SRCLIB_DIRS="$AP_BUILD_SRCLIB_DIRS pcre"
94 +  AP_CLEAN_SRCLIB_DIRS="pcre $AP_CLEAN_SRCLIB_DIRS"
95 +fi
96  
97  echo $ac_n "${nl}Configuring Apache httpd ...${nl}"
98  
99 @@ -466,9 +470,6 @@
100  APACHE_HELP_STRING(--with-suexec-umask,umask for suexec'd process),[
101    AC_DEFINE_UNQUOTED(AP_SUEXEC_UMASK, 0$withval, [umask for suexec'd process] ) ] )
102  
103 -dnl AP_LIBS specifies the actual libraries. note we have some required libs.
104 -AP_LIBS="$abs_builddir/srclib/pcre/libpcre.la $AP_LIBS"
105 -
106  dnl APR should go after the other libs, so the right symbols can be picked up
107  AP_LIBS="$AP_LIBS `$apu_config --link-libtool --libs` `$apr_config --link-libtool --libs`"
108  APACHE_SUBST(AP_LIBS)
109 diff -x {arch} -x .arch-ids -urN orig/apache2/server/Makefile.in mod/apache2/server/Makefile.in
110 --- orig/apache2/server/Makefile.in     2004-03-07 03:18:46.000000000 -0500
111 +++ mod/apache2/server/Makefile.in      2004-03-07 02:52:53.000000000 -0500
112 @@ -9,7 +9,7 @@
113  LTLIBRARY_NAME    = libmain.la
114  LTLIBRARY_SOURCES = \
115      test_char.h \
116 -       config.c log.c main.c vhost.c util.c \
117 +       config.c log.c main.c vhost.c util.c util_pcre.c \
118         util_script.c util_md5.c util_cfgtree.c util_ebcdic.c util_time.c \
119         rfc1413.c connection.c listen.c \
120         mpm_common.c util_charset.c util_debug.c util_xml.c \
121 diff -x {arch} -x .arch-ids -urN orig/apache2/server/util.c mod/apache2/server/util.c
122 --- orig/apache2/server/util.c  2004-03-07 03:18:48.000000000 -0500
123 +++ mod/apache2/server/util.c   2004-03-07 03:03:54.000000000 -0500
124 @@ -298,7 +298,7 @@
125  
126  static apr_status_t regex_cleanup(void *preg)
127  {
128 -    regfree((regex_t *) preg);
129 +    ap_regfree((regex_t *) preg);
130      return APR_SUCCESS;
131  }
132  
133 @@ -307,7 +307,7 @@
134  {
135      regex_t *preg = apr_palloc(p, sizeof(regex_t));
136  
137 -    if (regcomp(preg, pattern, cflags)) {
138 +    if (ap_regcomp(preg, pattern, cflags)) {
139          return NULL;
140      }
141  
142 @@ -319,7 +319,7 @@
143  
144  AP_DECLARE(void) ap_pregfree(apr_pool_t *p, regex_t * reg)
145  {
146 -    regfree(reg);
147 +    ap_regfree(reg);
148      apr_pool_cleanup_kill(p, (void *) reg, regex_cleanup);
149  }
150  
151 @@ -386,25 +386,6 @@
152      return bigstring;
153  }
154  
155 -/* 
156 - * Apache stub function for the regex libraries regexec() to make sure the
157 - * whole regex(3) API is available through the Apache (exported) namespace.
158 - * This is especially important for the DSO situations of modules.
159 - * DO NOT MAKE A MACRO OUT OF THIS FUNCTION!
160 - */
161 -AP_DECLARE(int) ap_regexec(regex_t *preg, const char *string,
162 -                           size_t nmatch, regmatch_t pmatch[], int eflags)
163 -{
164 -    return regexec(preg, string, nmatch, pmatch, eflags);
165 -}
166 -
167 -AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg, char *errbuf,
168 -                               size_t errbuf_size)
169 -{
170 -    return regerror(errcode, preg, errbuf, errbuf_size);
171 -}
172 -
173 -
174  /* This function substitutes for $0-$9, filling in regular expression
175   * submatches. Pass it the same nmatch and pmatch arguments that you
176   * passed ap_regexec(). pmatch should not be greater than the maximum number
177 diff -x {arch} -x .arch-ids -urN orig/apache2/server/util_pcre.c mod/apache2/server/util_pcre.c
178 --- orig/apache2/server/util_pcre.c     1969-12-31 19:00:00.000000000 -0500
179 +++ mod/apache2/server/util_pcre.c      2004-03-07 03:14:49.000000000 -0500
180 @@ -0,0 +1,254 @@
181 +/*************************************************
182 +*      Perl-Compatible Regular Expressions       *
183 +*************************************************/
184 +
185 +/*
186 +This is a library of functions to support regular expressions whose syntax
187 +and semantics are as close as possible to those of the Perl 5 language. See
188 +the file Tech.Notes for some information on the internals.
189 +
190 +This module is a wrapper that provides a POSIX API to the underlying PCRE
191 +functions.
192 +
193 +Written by: Philip Hazel <ph10@cam.ac.uk>
194 +
195 +           Copyright (c) 1997-2003 University of Cambridge
196 +          Copyright (C) 2004  Andres Salomon <dilinger@voxel.net>
197 +
198 +-----------------------------------------------------------------------------
199 +Permission is granted to anyone to use this software for any purpose on any
200 +computer system, and to redistribute it freely, subject to the following
201 +restrictions:
202 +
203 +1. This software is distributed in the hope that it will be useful,
204 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
205 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
206 +
207 +2. The origin of this software must not be misrepresented, either by
208 +   explicit claim or by omission.
209 +
210 +3. Altered versions must be plainly marked as such, and must not be
211 +   misrepresented as being the original software.
212 +
213 +4. If PCRE is embedded in any software that is released under the GNU
214 +   General Purpose Licence (GPL), then the terms of that licence shall
215 +   supersede any condition above with which it is incompatible.
216 +----------------------------------------------------------------------------
217 +*/
218 +
219 +#include "apr.h"
220 +#include "apr_strings.h"
221 +#include "apr_lib.h"
222 +                                                                                
223 +#define APR_WANT_STDIO
224 +#define APR_WANT_STRFUNC
225 +#include "apr_want.h"
226 +                                                                                
227 +#if APR_HAVE_UNISTD_H
228 +#include <unistd.h>
229 +#endif
230 +#if APR_HAVE_NETDB_H
231 +#include <netdb.h>              /* for gethostbyname() */
232 +#endif
233 +
234 +#define CORE_PRIVATE
235 +                                                                                
236 +#include "ap_config.h"
237 +#include "apr_base64.h"
238 +#include "httpd.h"
239 +#include "http_main.h"
240 +#include "http_log.h"
241 +#include "http_protocol.h"
242 +#include "http_config.h"
243 +#include "util_ebcdic.h"
244 +                                                                                
245 +#include <pcre.h>
246 +
247 +#ifndef PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
248 +#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
249 +#endif
250 +
251 +/* Table of texts corresponding to POSIX error codes */
252 +
253 +static const char *pstring[] = {
254 +  "",                                /* Dummy for value 0 */
255 +  "internal error",                  /* REG_ASSERT */
256 +  "invalid repeat counts in {}",     /* BADBR      */
257 +  "pattern error",                   /* BADPAT     */
258 +  "? * + invalid",                   /* BADRPT     */
259 +  "unbalanced {}",                   /* EBRACE     */
260 +  "unbalanced []",                   /* EBRACK     */
261 +  "collation error - not relevant",  /* ECOLLATE   */
262 +  "bad class",                       /* ECTYPE     */
263 +  "bad escape sequence",             /* EESCAPE    */
264 +  "empty expression",                /* EMPTY      */
265 +  "unbalanced ()",                   /* EPAREN     */
266 +  "bad range inside []",             /* ERANGE     */
267 +  "expression too big",              /* ESIZE      */
268 +  "failed to get memory",            /* ESPACE     */
269 +  "bad back reference",              /* ESUBREG    */
270 +  "bad argument",                    /* INVARG     */
271 +  "match failed"                     /* NOMATCH    */
272 +};
273 +
274 +
275 +
276 +
277 +/*************************************************
278 +*          Translate error code to string        *
279 +*************************************************/
280 +
281 +AP_DECLARE(size_t)
282 +ap_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
283 +{
284 +const char *message, *addmessage;
285 +size_t length, addlength;
286 +
287 +message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
288 +  "unknown error code" : pstring[errcode];
289 +length = strlen(message) + 1;
290 +
291 +addmessage = " at offset ";
292 +addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
293 +  strlen(addmessage) + 6 : 0;
294 +
295 +if (errbuf_size > 0)
296 +  {
297 +  if (addlength > 0 && errbuf_size >= length + addlength)
298 +    sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
299 +  else
300 +    {
301 +    strncpy(errbuf, message, errbuf_size - 1);
302 +    errbuf[errbuf_size-1] = 0;
303 +    }
304 +  }
305 +
306 +return length + addlength;
307 +}
308 +
309 +
310 +
311 +
312 +/*************************************************
313 +*           Free store held by a regex           *
314 +*************************************************/
315 +
316 +void
317 +ap_regfree(regex_t *preg)
318 +{
319 +(pcre_free)(preg->re_pcre);
320 +}
321 +
322 +
323 +
324 +
325 +/*************************************************
326 +*            Compile a regular expression        *
327 +*************************************************/
328 +
329 +/*
330 +Arguments:
331 +  preg        points to a structure for recording the compiled expression
332 +  pattern     the pattern to compile
333 +  cflags      compilation flags
334 +
335 +Returns:      0 on success
336 +              various non-zero codes on failure
337 +*/
338 +
339 +int
340 +ap_regcomp(regex_t *preg, const char *pattern, int cflags)
341 +{
342 +const char *errorptr;
343 +int erroffset;
344 +int options = 0;
345 +
346 +if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;
347 +if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
348 +
349 +preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
350 +preg->re_erroffset = erroffset;
351 +
352 +if (preg->re_pcre == NULL) return 1;
353 +
354 +preg->re_nsub = pcre_info(preg->re_pcre, NULL, NULL);
355 +return 0;
356 +}
357 +
358 +
359 +
360 +
361 +/*************************************************
362 +*              Match a regular expression        *
363 +*************************************************/
364 +
365 +/* Unfortunately, PCRE requires 3 ints of working space for each captured
366 +substring, so we have to get and release working store instead of just using
367 +the POSIX structures as was done in earlier releases when PCRE needed only 2
368 +ints. However, if the number of possible capturing brackets is small, use a
369 +block of store on the stack, to reduce the use of malloc/free. The threshold is
370 +in a macro that can be changed at configure time. */
371 +
372 +AP_DECLARE(int)
373 +ap_regexec(regex_t *preg, const char *string, size_t nmatch,
374 +  regmatch_t pmatch[], int eflags)
375 +{
376 +int rc;
377 +int options = 0;
378 +int *ovector = NULL;
379 +int small_ovector[PCRE_CONFIG_POSIX_MALLOC_THRESHOLD * 3];
380 +int allocated_ovector = 0;
381 +
382 +if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
383 +if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
384 +
385 +((regex_t *)preg)->re_erroffset = (size_t)(-1);  /* Only has meaning after compile */
386 +
387 +if (nmatch > 0)
388 +  {
389 +  if (nmatch <= PCRE_CONFIG_POSIX_MALLOC_THRESHOLD)
390 +    {
391 +    ovector = &(small_ovector[0]);
392 +    }
393 +  else
394 +    {
395 +    ovector = (int *)malloc(sizeof(int) * nmatch * 3);
396 +    if (ovector == NULL) return REG_ESPACE;
397 +    allocated_ovector = 1;
398 +    }
399 +  }
400 +
401 +rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options,
402 +  ovector, nmatch * 3);
403 +
404 +if (rc == 0) rc = nmatch;    /* All captured slots were filled in */
405 +
406 +if (rc >= 0)
407 +  {
408 +  size_t i;
409 +  for (i = 0; i < (size_t)rc; i++)
410 +    {
411 +    pmatch[i].rm_so = ovector[i*2];
412 +    pmatch[i].rm_eo = ovector[i*2+1];
413 +    }
414 +  if (allocated_ovector) free(ovector);
415 +  for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
416 +  return 0;
417 +  }
418 +
419 +else
420 +  {
421 +  if (allocated_ovector) free(ovector);
422 +  switch(rc)
423 +    {
424 +    case PCRE_ERROR_NOMATCH: return REG_NOMATCH;
425 +    case PCRE_ERROR_NULL: return REG_INVARG;
426 +    case PCRE_ERROR_BADOPTION: return REG_INVARG;
427 +    case PCRE_ERROR_BADMAGIC: return REG_INVARG;
428 +    case PCRE_ERROR_UNKNOWN_NODE: return REG_ASSERT;
429 +    case PCRE_ERROR_NOMEMORY: return REG_ESPACE;
430 +    default: return REG_ASSERT;
431 +    }
432 +  }
433 +}
434 +
435 diff -x {arch} -x .arch-ids -urN orig/apache2/srclib/Makefile.in mod/apache2/srclib/Makefile.in
436 --- orig/apache2/srclib/Makefile.in     2004-03-07 03:18:49.000000000 -0500
437 +++ mod/apache2/srclib/Makefile.in      2004-03-07 01:18:07.000000000 -0500
438 @@ -1,5 +1,5 @@
439  
440 -SUBDIRS = pcre
441 +SUBDIRS = 
442  BUILD_SUBDIRS = $(AP_BUILD_SRCLIB_DIRS)
443  CLEAN_SUBDIRS = $(AP_CLEAN_SRCLIB_DIRS)
This page took 0.752402 seconds and 3 git commands to generate.