-const char pcrs_rcs[] = "$Id: pcrs.c,v 1.16 2001/11/30 21:32:14 jongfoster Exp $";
+const char pcrs_rcs[] = "$Id: pcrs.c,v 1.17 2002/03/08 13:45:48 oes Exp $";
/*********************************************************************
*
*
* Revisions :
* $Log: pcrs.c,v $
+ * Revision 1.17 2002/03/08 13:45:48 oes
+ * Hiding internal functions
+ *
* Revision 1.16 2001/11/30 21:32:14 jongfoster
* Fixing signed/unsigned comparison (Andreas please check this!)
* One tab->space
*********************************************************************/
static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int trivialflag, int capturecount, int *errptr)
{
- int length, i, k, l, quoted;
+ int i, k, l, quoted;
+ size_t length;
char *text;
pcrs_substitute *r;
*********************************************************************/
pcrs_job *pcrs_compile_command(const char *command, int *errptr)
{
- int i, k, l, limit, quoted = FALSE;
+ int i, k, l, quoted = FALSE;
+ size_t limit;
char delimiter;
char *tokens[4];
pcrs_job *newjob;
offset,
i, k,
matches_found,
- newsize,
submatches,
max_matches = PCRS_MAX_MATCH_INIT;
+ size_t newsize;
pcrs_match *matches, *dummy;
char *result_offset;
* Find the pattern and calculate the space
* requirements for the result
*/
- newsize=subject_length;
+ newsize = subject_length;
- while ((submatches = pcre_exec(job->pattern, job->hints, subject, subject_length, offset, 0, offsets, 3 * PCRS_MAX_SUBMATCHES)) > 0)
+ while ((submatches = pcre_exec(job->pattern, job->hints, subject, (int) subject_length, offset, 0, offsets, 3 * PCRS_MAX_SUBMATCHES)) > 0)
{
job->flags |= PCRS_SUCCESS;
matches[i].submatches = submatches;
for (i=0; i < matches_found; i++)
{
/* copy the chunk preceding the match */
- memcpy(result_offset, subject + offset, matches[i].submatch_offset[0] - offset);
+ memcpy(result_offset, subject + offset, (size_t) matches[i].submatch_offset[0] - offset);
result_offset += matches[i].submatch_offset[0] - offset;
/* For every segment of the substitute.. */
*
* Revisions :
* $Log: pcrs.h,v $
+ * Revision 1.10 2002/03/08 13:44:48 oes
+ * Hiding internal functions, preventing double inclusion of pcre.h
+ *
* Revision 1.9 2001/08/18 11:35:29 oes
* - Introduced pcrs_strerror()
* - added pcrs_execute_list()
*
*********************************************************************/
-#define PCRS_H_VERSION "$Id: pcrs.h,v 1.9 2001/08/18 11:35:29 oes Exp $"
+#define PCRS_H_VERSION "$Id: pcrs.h,v 1.10 2002/03/08 13:44:48 oes Exp $"
\f
#ifndef _PCRE_H
/* A compiled substitute */
typedef struct {
- char *text; /* The plaintext part of the substitute, with all backreferences stripped */
- int backrefs; /* The number of backreferences */
- int block_offset[PCRS_MAX_SUBMATCHES]; /* Array with the offsets of all plaintext blocks in text */
- int block_length[PCRS_MAX_SUBMATCHES]; /* Array with the lengths of all plaintext blocks in text */
- int backref[PCRS_MAX_SUBMATCHES]; /* Array with the backref number for all plaintext block borders */
- int backref_count[PCRS_MAX_SUBMATCHES + 2]; /* Array with the number of references to each backref index */
+ char *text; /* The plaintext part of the substitute, with all backreferences stripped */
+ int backrefs; /* The number of backreferences */
+ int block_offset[PCRS_MAX_SUBMATCHES]; /* Array with the offsets of all plaintext blocks in text */
+ size_t block_length[PCRS_MAX_SUBMATCHES]; /* Array with the lengths of all plaintext blocks in text */
+ int backref[PCRS_MAX_SUBMATCHES]; /* Array with the backref number for all plaintext block borders */
+ int backref_count[PCRS_MAX_SUBMATCHES + 2]; /* Array with the number of references to each backref index */
} pcrs_substitute;
*/
typedef struct {
- int submatches; /* Number of captured subpatterns */
- int submatch_offset[PCRS_MAX_SUBMATCHES + 2]; /* Offset for each submatch in the subject */
- int submatch_length[PCRS_MAX_SUBMATCHES + 2]; /* Length of each submatch in the subject */
+ int submatches; /* Number of captured subpatterns */
+ int submatch_offset[PCRS_MAX_SUBMATCHES + 2]; /* Offset for each submatch in the subject */
+ size_t submatch_length[PCRS_MAX_SUBMATCHES + 2]; /* Length of each submatch in the subject */
} pcrs_match;