X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=pcrs.c;h=f1d55f6157b1de6badba5b7dc037aa3bdc341930;hp=dd1674f3b4424c07144c86dce9eb4dd6aaff6a06;hb=7d7d862f59e3706f4ac1d21f26d4fac3a60dc073;hpb=72081f829de368392d04076728f8c991178c0080 diff --git a/pcrs.c b/pcrs.c index dd1674f3..f1d55f61 100644 --- a/pcrs.c +++ b/pcrs.c @@ -1,8 +1,8 @@ -const char pcrs_rcs[] = "$Id: pcrs.c,v 1.19.2.4 2005/05/07 21:50:55 david__schmidt Exp $"; +const char pcrs_rcs[] = "$Id: pcrs.c,v 1.21 2006/07/18 14:48:47 david__schmidt Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/Attic/pcrs.c,v $ + * File : $Source: /cvsroot/ijbswa/current/pcrs.c,v $ * * Purpose : pcrs is a supplement to the pcre library by Philip Hazel * and adds Perl-style substitution. That @@ -33,6 +33,10 @@ const char pcrs_rcs[] = "$Id: pcrs.c,v 1.19.2.4 2005/05/07 21:50:55 david__schmi * * Revisions : * $Log: pcrs.c,v $ + * Revision 1.21 2006/07/18 14:48:47 david__schmidt + * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch) + * with what was really the latest development (the v_3_0_branch branch) + * * Revision 1.19.2.4 2005/05/07 21:50:55 david__schmidt * A few memory leaks plugged (mostly on error paths) * @@ -196,6 +200,13 @@ const char *pcrs_strerror(const int error) case PCRE_ERROR_NOSUBSTRING: return "(pcre:) Fire in power supply"; case PCRE_ERROR_NOMATCH: return "(pcre:) Water in power supply"; +#ifdef PCRE_ERROR_MATCHLIMIT + /* + * Only reported by PCRE versions newer than our own. + */ + case PCRE_ERROR_MATCHLIMIT: return "(pcre:) Match limit reached"; +#endif /* def PCRE_ERROR_MATCHLIMIT */ + /* PCRS errors: */ case PCRS_ERR_NOMEM: return "(pcrs:) No memory"; case PCRS_ERR_CMDSYNTAX: return "(pcrs:) Syntax error while parsing command"; @@ -203,8 +214,13 @@ const char *pcrs_strerror(const int error) case PCRS_ERR_BADJOB: return "(pcrs:) Bad job - NULL job, pattern or substitute"; case PCRS_WARN_BADREF: return "(pcrs:) Backreference out of range"; - /* What's that? */ - default: return "Unknown error"; + /* + * XXX: With the exception of PCRE_ERROR_MATCHLIMIT we + * only catch PCRE errors that can happen with our internal + * version. If Privoxy is linked against a newer + * PCRE version all bets are off ... + */ + default: return "Unknown error. Privoxy out of sync with PCRE?"; } } /* error >= 0: No error */ @@ -740,8 +756,8 @@ pcrs_job *pcrs_compile(const char *pattern, const char *substitute, const char * * * Returns : On success, the number of substitutions that were made. * May be > 1 if job->flags contained PCRS_GLOBAL - * On failiure, the (negative) pcre error code describing the - * failiure, which may be translated to text using pcrs_strerror(). + * On failure, the (negative) pcre error code describing the + * failure, which may be translated to text using pcrs_strerror(). * *********************************************************************/ int pcrs_execute_list(pcrs_job *joblist, char *subject, size_t subject_length, char **result, size_t *result_length) @@ -800,8 +816,8 @@ int pcrs_execute_list(pcrs_job *joblist, char *subject, size_t subject_length, c * * Returns : On success, the number of substitutions that were made. * May be > 1 if job->flags contained PCRS_GLOBAL - * On failiure, the (negative) pcre error code describing the - * failiure, which may be translated to text using pcrs_strerror(). + * On failure, the (negative) pcre error code describing the + * failure, which may be translated to text using pcrs_strerror(). * *********************************************************************/ int pcrs_execute(pcrs_job *job, char *subject, size_t subject_length, char **result, size_t *result_length) @@ -821,7 +837,7 @@ int pcrs_execute(pcrs_job *job, char *subject, size_t subject_length, char **res /* * Sanity check & memory allocation */ - if (job == NULL || job->pattern == NULL || job->substitute == NULL) + if (job == NULL || job->pattern == NULL || job->substitute == NULL || NULL == subject) { *result = NULL; return(PCRS_ERR_BADJOB);