From 4b3c9b925e5be187be35cb31f797dcd34ee2d255 Mon Sep 17 00:00:00 2001 From: Gabor Liptak Date: Thu, 4 Apr 2002 00:36:36 +0000 Subject: [PATCH] always use pcre for matching --- GNUmakefile.in | 10 +++++---- acconfig.h | 10 +++------ cgisimple.c | 11 ++++------ config.h.win | 10 +++------ config.h.win32threads.win | 11 +++------- configure.in | 44 +++++++-------------------------------- project.h | 27 ++++++++---------------- urlmatch.c | 20 ++++-------------- w32log.c | 25 +++++----------------- 9 files changed, 44 insertions(+), 124 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index 37c86943..5da6a33b 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -1,6 +1,6 @@ # Note: Makefile is built automatically from Makefile.in # -# $Id: GNUmakefile.in,v 1.55 2002/04/03 19:54:29 swa Exp $ +# $Id: GNUmakefile.in,v 1.56 2002/04/03 22:28:03 gliptak Exp $ # # Written by and Copyright (C) 2001 the SourceForge # Privoxy team. http://www.privoxy.org/ @@ -150,10 +150,9 @@ PCRE_SRC = @STATIC_PCRE_ONLY@pcre/get.c pcre/maketables.c pcre/study.c pcre/ PCRE_OBJS = @STATIC_PCRE_ONLY@$(PCRE_SRC:.c=.@OBJEXT@) PCRE_HDRS = @STATIC_PCRE_ONLY@pcre/config.h pcre/chartables.c pcre/internal.h pcre/pcre.h -# No REGEX (Either because dynamically linked pcreposix, or no regex at all): +# No REGEX (maybe because dynamically linked pcreposix): REGEX_SRC = -# PCRE REGEX: -@PCRE_REGEX_ONLY@@STATIC_PCRE_ONLY@REGEX_SRC = pcre/pcreposix.c +@STATIC_PCRE_ONLY@REGEX_SRC = pcre/pcreposix.c REGEX_OBJS = $(REGEX_SRC:.c=.@OBJEXT@) REGEX_HDRS = $(REGEX_SRC:.c=.h) @@ -700,6 +699,9 @@ install: all ## end: # $Log: GNUmakefile.in,v $ +# Revision 1.56 2002/04/03 22:28:03 gliptak +# Removed references to gnu_regex +# # Revision 1.55 2002/04/03 19:54:29 swa # freebsd tested to work. attempt to move tarball dist target forward # diff --git a/acconfig.h b/acconfig.h index a7c60476..20661322 100644 --- a/acconfig.h +++ b/acconfig.h @@ -37,6 +37,9 @@ * * Revisions : * $Log: acconfig.h,v $ + * Revision 1.23 2002/04/03 22:28:03 gliptak + * Removed references to gnu_regex + * * Revision 1.22 2002/03/26 22:29:54 swa * we have a new homepage! * @@ -222,13 +225,6 @@ */ #undef CODE_STATUS -/* - * Regular expression matching for URLs. (Highly recommended). - * If neither of these are defined then you can ony use prefix matching. - * Don't bother to change this here! Use configure instead. - */ -#undef REGEX_PCRE - /* * Should pcre be statically built in instead of linkling with libpcre? * (This is determined by configure depending on the availiability of diff --git a/cgisimple.c b/cgisimple.c index 326c5e4a..701d3d81 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -1,4 +1,4 @@ -const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.24 2002/04/02 16:12:47 oes Exp $"; +const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.25 2002/04/03 22:28:03 gliptak Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $ @@ -36,6 +36,9 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.24 2002/04/02 16:12:47 oes Ex * * Revisions : * $Log: cgisimple.c,v $ + * Revision 1.25 2002/04/03 22:28:03 gliptak + * Removed references to gnu_regex + * * Revision 1.24 2002/04/02 16:12:47 oes * Fix: moving misplaced lines into #ifdef FEATURE_FORCE * @@ -1174,12 +1177,6 @@ static jb_err show_defines(struct map *exports) if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0); #endif /* ndef FEATURE_TRUST */ -#ifdef REGEX_PCRE - if (!err) err = map_conditional(exports, "REGEX_PCRE", 1); -#else /* ifndef REGEX_PCRE */ - if (!err) err = map_conditional(exports, "REGEX_PCRE", 0); -#endif /* def REGEX_PCRE */ - #ifdef STATIC_PCRE if (!err) err = map_conditional(exports, "STATIC_PCRE", 1); #else /* ifndef STATIC_PCRE */ diff --git a/config.h.win b/config.h.win index fdb144e5..ce13e57f 100755 --- a/config.h.win +++ b/config.h.win @@ -37,6 +37,9 @@ * * Revisions : * $Log: config.h.win,v $ + * Revision 1.20 2002/04/03 22:28:03 gliptak + * Removed references to gnu_regex + * * Revision 1.19 2002/03/26 22:29:54 swa * we have a new homepage! * @@ -208,13 +211,6 @@ */ #define CODE_STATUS "beta" -/* - * Regular expression matching for URLs. (Highly recommended). - * If neither of these are defined then you can ony use prefix matching. - * Don't bother to change this here! Use configure instead. - */ -#define REGEX_PCRE 1 - /* * Should pcre be statically built in instead of linkling with libpcre? * (This is determined by configure depending on the availiability of diff --git a/config.h.win32threads.win b/config.h.win32threads.win index ac28b767..d444ea45 100644 --- a/config.h.win32threads.win +++ b/config.h.win32threads.win @@ -37,6 +37,9 @@ * * Revisions : * $Log: config.h.win32threads.win,v $ + * Revision 1.14 2002/03/26 22:29:54 swa + * we have a new homepage! + * * Revision 1.13 2002/03/24 17:08:12 jongfoster * Version number bump * @@ -205,14 +208,6 @@ */ #define CODE_STATUS "beta" -/* - * Regular expression matching for URLs. (Highly recommended). - * If neither of these are defined then you can ony use prefix matching. - * Don't bother to change this here! Use configure instead. - */ -/* #define REGEX_GNU 1 */ -#define REGEX_PCRE 1 - /* * Should pcre be statically built in instead of linkling with libpcre? * (This is determined by configure depending on the availiability of diff --git a/configure.in b/configure.in index 42167167..d225683e 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl $Id: configure.in,v 1.55 2002/04/03 03:54:38 gliptak Exp $ +dnl $Id: configure.in,v 1.56 2002/04/03 22:28:03 gliptak Exp $ dnl dnl Written by and Copyright (C) 2001, 2002 the SourceForge dnl Privoxy team. http://www.privoxy.org/ @@ -28,6 +28,9 @@ dnl or write to the Free Software Foundation, Inc., 59 dnl Temple Place - Suite 330, Boston, MA 02111-1307, USA. dnl dnl $Log: configure.in,v $ +dnl Revision 1.56 2002/04/03 22:28:03 gliptak +dnl Removed references to gnu_regex +dnl dnl Revision 1.55 2002/04/03 03:54:38 gliptak dnl Checking pcre version dnl @@ -321,7 +324,7 @@ dnl ================================================================= dnl AutoConf Initialization dnl ================================================================= -AC_REVISION($Revision: 1.55 $) +AC_REVISION($Revision: 1.56 $) AC_INIT(jcc.c) AC_CONFIG_HEADER([config.h]) AC_CANONICAL_HOST @@ -965,14 +968,6 @@ dnl pcre/pcrs is needed for CGI anyway, so dnl the choice is only between static and dnl dynamic: -AC_ARG_ENABLE(regex-matching, -[ --enable-regex-matching=pcre Use perl-compatible regex for actionsfile - pattern matching (default) - --disable-regex-matching Don't use regex matching, compare URL - prefix instead (won't shrink birary)], -[ regex_matching=$enableval ], -[ regex_matching=pcre ]) - AC_ARG_ENABLE(dynamic-pcre, [ --disable-dynamic-pcre Use the built-in, static pcre, even if libpcre is available], @@ -984,24 +979,15 @@ AC_ARG_ENABLE(dynamic-pcrs, [ if test $enableval = "no"; then have_pcrs=no; fi ]) -# Is the regex URL matching based on libpcreposix, but we -# don't have that library? -# -if test $have_pcreposix = "yes" -o $regex_matching != "pcre"; then - dont_miss_pcreposix=yes -else - dont_miss_pcreposix=no -fi - # If we have libpcre and either we also have pcreposix or # we don't need pcreposix, then link pcre dynamically; else # build it and link statically # -if test $have_pcre = "yes" -a $dont_miss_pcreposix = "yes"; then +if test $have_pcre = "yes"; then echo "using libpcre" pcre_dyn=yes STATIC_PCRE_ONLY=# - LIBS="$LIBS -lpcre" + LIBS="$LIBS -lpcre -lpcreposix" else echo "using built-in static pcre" pcre_dyn=no @@ -1023,22 +1009,6 @@ else STATIC_PCRS_ONLY= fi -# Which method should be used for URL matching? -# pcre or prefix matching? -# -if test $regex_matching = "pcre"; then - echo "using pcre regex for URL matching" - AC_DEFINE(REGEX_PCRE) - PCRE_REGEX_ONLY= - if test $pcre_dyn = "yes"; then - LIBS="$LIBS -lpcreposix" - fi -else - echo -e "using prefix matching for URLs\nHint: This does NOT make the executable any smaller!" - PCRE_REGEX_ONLY=# -fi - -AC_SUBST(PCRE_REGEX_ONLY) AC_SUBST(STATIC_PCRE_ONLY) AC_SUBST(STATIC_PCRS_ONLY) diff --git a/project.h b/project.h index e9502848..ca8ea3af 100644 --- a/project.h +++ b/project.h @@ -1,6 +1,6 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED -#define PROJECT_H_VERSION "$Id: project.h,v 1.63 2002/03/31 17:19:00 jongfoster Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.64 2002/04/03 22:28:03 gliptak Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -36,6 +36,9 @@ * * Revisions : * $Log: project.h,v $ + * Revision 1.64 2002/04/03 22:28:03 gliptak + * Removed references to gnu_regex + * * Revision 1.63 2002/03/31 17:19:00 jongfoster * Win32 only: Enabling STRICT to fix a VC++ compile warning. * @@ -423,10 +426,6 @@ * and are included anyway. */ -#if defined(REGEX_PCRE) -# define REGEX -#endif /* defined(REGEX_PCRE) */ - #ifdef STATIC_PCRE # include "pcre.h" #else @@ -439,13 +438,11 @@ # include #endif -#if defined(REGEX_PCRE) -# ifdef STATIC_PCRE -# include "pcreposix.h" -# else -# include -# endif -#endif /* defined(REGEX_PCRE) */ +#ifdef STATIC_PCRE +# include "pcreposix.h" +#else +# include +#endif #ifdef AMIGA #include "amiga.h" @@ -632,15 +629,9 @@ struct url_spec char *path; /* The path prefix (if not using regex), or source */ /* for the regex. */ int pathlen; /* ==strlen(path). Needed for prefix matching. */ -#ifdef REGEX regex_t *preg; /* Regex for matching path part */ -#endif }; -#ifdef REGEX #define URL_SPEC_INITIALIZER { NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL } -#else /* ifndef REGEX */ -#define URL_SPEC_INITIALIZER { NULL, NULL, NULL, 0, 0, 0, NULL, 0 } -#endif /* ndef REGEX */ /* Constants for host part matching in URLs */ #define ANCHOR_LEFT 1 diff --git a/urlmatch.c b/urlmatch.c index bdc58ee6..80a18424 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.7 2002/03/26 22:29:55 swa Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.8 2002/04/03 23:32:47 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -33,6 +33,9 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.7 2002/03/26 22:29:55 swa Exp $ * * Revisions : * $Log: urlmatch.c,v $ + * Revision 1.8 2002/04/03 23:32:47 jongfoster + * Fixing memory leak on error + * * Revision 1.7 2002/03/26 22:29:55 swa * we have a new homepage! * @@ -635,7 +638,6 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) url->path = NULL; url->pathlen = 0; } -#ifdef REGEX if (url->path) { int errcode; @@ -674,7 +676,6 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) return JB_ERR_PARSE; } } -#endif if ((p = strchr(buf, ':')) == NULL) { url->port = 0; @@ -707,10 +708,8 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) { freez(url->spec); freez(url->path); -#ifdef REGEX regfree(url->preg); freez(url->preg); -#endif /* def REGEX */ return JB_ERR_MEMORY; } @@ -727,10 +726,8 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) { freez(url->spec); freez(url->path); -#ifdef REGEX regfree(url->preg); freez(url->preg); -#endif /* def REGEX */ freez(url->dbuffer); url->dcount = 0; return JB_ERR_MEMORY; @@ -746,10 +743,8 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) { freez(url->spec); freez(url->path); -#ifdef REGEX regfree(url->preg); freez(url->preg); -#endif /* def REGEX */ freez(url->dbuffer); url->dcount = 0; return JB_ERR_MEMORY; @@ -785,14 +780,11 @@ void free_url_spec(struct url_spec *url) freez(url->dbuffer); freez(url->dvec); freez(url->path); -#ifdef REGEX if (url->preg) { regfree(url->preg); freez(url->preg); } -#endif - } @@ -815,11 +807,7 @@ int url_match(const struct url_spec *pattern, return ((pattern->port == 0) || (pattern->port == url->port)) && ((pattern->dbuffer == NULL) || (domain_match(pattern, url) == 0)) && ((pattern->path == NULL) || -#ifdef REGEX (regexec(pattern->preg, url->path, 0, NULL, 0) == 0) -#else - (strncmp(pattern->path, url->path, pattern->pathlen) == 0) -#endif ); } diff --git a/w32log.c b/w32log.c index 7cb41ffc..ada06b2e 100644 --- a/w32log.c +++ b/w32log.c @@ -1,4 +1,4 @@ -const char w32log_rcs[] = "$Id: w32log.c,v 1.23 2002/03/26 22:57:10 jongfoster Exp $"; +const char w32log_rcs[] = "$Id: w32log.c,v 1.24 2002/03/31 17:19:00 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/w32log.c,v $ @@ -32,6 +32,9 @@ const char w32log_rcs[] = "$Id: w32log.c,v 1.23 2002/03/26 22:57:10 jongfoster E * * Revisions : * $Log: w32log.c,v $ + * Revision 1.24 2002/03/31 17:19:00 jongfoster + * Win32 only: Enabling STRICT to fix a VC++ compile warning. + * * Revision 1.23 2002/03/26 22:57:10 jongfoster * Web server name should begin www. * @@ -253,8 +256,6 @@ const char * g_trustfile = NULL; /* FIXME: end kludge */ - -#ifdef REGEX /* Regular expression for detected URLs */ #define RE_URL "http:[^ \n\r]*" @@ -300,8 +301,6 @@ static struct _Pattern /* this is the terminator statement - do not delete! */ { NULL, STYLE_NONE } }; -#endif /* def REGEX */ - /* * Public variables @@ -417,14 +416,11 @@ void TermLogWindow(void) *********************************************************************/ void LogCreatePatternMatchingBuffers(void) { -#ifdef REGEX int i; for (i = 0; patterns_to_highlight[i].str != NULL; i++) { regcomp(&patterns_to_highlight[i].buffer, patterns_to_highlight[i].str, REG_ICASE); } -#endif - } @@ -441,14 +437,11 @@ void LogCreatePatternMatchingBuffers(void) *********************************************************************/ void LogDestroyPatternMatchingBuffers(void) { -#ifdef REGEX int i; for (i = 0; patterns_to_highlight[i].str != NULL; i++) { regfree(&patterns_to_highlight[i].buffer); } -#endif - } @@ -466,7 +459,6 @@ void LogDestroyPatternMatchingBuffers(void) char *LogGetURLUnderCursor(void) { char *szResult = NULL; -#ifdef REGEX regex_t re; POINT ptCursor; POINTL ptl; @@ -509,7 +501,6 @@ char *LogGetURLUnderCursor(void) regfree(&re); } -#endif return szResult; } @@ -520,7 +511,7 @@ char *LogGetURLUnderCursor(void) * Function : LogPutString * * Description : Inserts text into the logging window. This is really - * a REGEXP aware wrapper function to `LogPutStringNoMatch'. + * a regexp aware wrapper function to `LogPutStringNoMatch'. * * Parameters : * 1 : pszText = pointer to string going to the log window @@ -532,9 +523,7 @@ char *LogGetURLUnderCursor(void) *********************************************************************/ int LogPutString(const char *pszText) { -#ifdef REGEX int i; -#endif int result = 0; if (pszText == NULL || strlen(pszText) == 0) @@ -552,7 +541,6 @@ int LogPutString(const char *pszText) */ EnterCriticalSection(&g_criticalsection); -#ifdef REGEX if (g_bHighlightMessages) { regmatch_t match; @@ -607,13 +595,10 @@ int LogPutString(const char *pszText) } } } -#endif result = LogPutStringNoMatch(pszText, STYLE_NONE); -#ifdef REGEX end: -#endif LeaveCriticalSection(&g_criticalsection); return result; -- 2.39.2