Fixing -Wconversion warnings
authoroes <oes@users.sourceforge.net>
Fri, 8 Mar 2002 14:18:23 +0000 (14:18 +0000)
committeroes <oes@users.sourceforge.net>
Fri, 8 Mar 2002 14:18:23 +0000 (14:18 +0000)
pcrs.c
pcrs.h

diff --git a/pcrs.c b/pcrs.c
index 8b23322..93c2e26 100644 (file)
--- a/pcrs.c
+++ b/pcrs.c
@@ -1,4 +1,4 @@
-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 $";
 
 /*********************************************************************
  *
 
 /*********************************************************************
  *
@@ -33,6 +33,9 @@ const char pcrs_rcs[] = "$Id: pcrs.c,v 1.16 2001/11/30 21:32:14 jongfoster Exp $
  *
  * Revisions   :
  *    $Log: pcrs.c,v $
  *
  * 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
  *    Revision 1.16  2001/11/30 21:32:14  jongfoster
  *    Fixing signed/unsigned comparison (Andreas please check this!)
  *    One tab->space
@@ -258,7 +261,8 @@ static int pcrs_parse_perl_options(const char *optstring, int *flags)
  *********************************************************************/
 static pcrs_substitute *pcrs_compile_replacement(const char *replacement, int trivialflag, int capturecount, int *errptr)
 {
  *********************************************************************/
 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;
 
    char *text;
    pcrs_substitute *r;
 
@@ -515,7 +519,8 @@ void pcrs_free_joblist(pcrs_job *joblist)
  *********************************************************************/
 pcrs_job *pcrs_compile_command(const char *command, int *errptr)
 {
  *********************************************************************/
 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;
    char delimiter;
    char *tokens[4];   
    pcrs_job *newjob;
@@ -772,9 +777,9 @@ int pcrs_execute(pcrs_job *job, char *subject, size_t subject_length, char **res
        offset,
        i, k,
        matches_found,
        offset,
        i, k,
        matches_found,
-       newsize,
        submatches,
        max_matches = PCRS_MAX_MATCH_INIT;
        submatches,
        max_matches = PCRS_MAX_MATCH_INIT;
+   size_t newsize;
    pcrs_match *matches, *dummy;
    char *result_offset;
 
    pcrs_match *matches, *dummy;
    char *result_offset;
 
@@ -801,9 +806,9 @@ int pcrs_execute(pcrs_job *job, char *subject, size_t subject_length, char **res
     * Find the pattern and calculate the space
     * requirements for the result
     */
     * 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;
    {
       job->flags |= PCRS_SUCCESS;
       matches[i].submatches = submatches;
@@ -888,7 +893,7 @@ int pcrs_execute(pcrs_job *job, char *subject, size_t subject_length, char **res
    for (i=0; i < matches_found; i++)
    {
       /* copy the chunk preceding the match */
    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.. */
       result_offset += matches[i].submatch_offset[0] - offset;
 
       /* For every segment of the substitute.. */
diff --git a/pcrs.h b/pcrs.h
index e6ab0e3..a14b816 100644 (file)
--- a/pcrs.h
+++ b/pcrs.h
@@ -11,6 +11,9 @@
  *
  * Revisions   :
  *    $Log: pcrs.h,v $
  *
  * 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()
  *    Revision 1.9  2001/08/18 11:35:29  oes
  *    - Introduced pcrs_strerror()
  *    - added pcrs_execute_list()
@@ -56,7 +59,7 @@
  *
  *********************************************************************/
 
  *
  *********************************************************************/
 
-#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
 \f
 
 #ifndef _PCRE_H
@@ -99,12 +102,12 @@ extern "C" {
 /* A compiled substitute */
 
 typedef struct {
 /* 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;
 
 
 } pcrs_substitute;
 
 
@@ -116,9 +119,9 @@ typedef struct {
  */
 
 typedef struct {
  */
 
 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;
 
 
 } pcrs_match;