-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
* <ph10@cam.ac.uk> and adds Perl-style substitution. That
*
* 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)
*
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";
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 */
*
* 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)
*
* 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)
/*
* 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);